Recently I have been working up some training lessons for .NET 5 using VSCode for my company, and have previously used a nuget.config (in the same folder as my solution file) as such:
<?xml version="1.0" encoding="utf-8"?><configuration><config><add key="globalPackagesFolder" value="..\lib\nuget" /></config><solution><add key="disableSourceControlIntegration" value="true" /></solution></configuration>
Which allows all of the restored packages for that solution to stay within the solution folder structure. And this works great for these transient training projects, however, while I can create a nuget.config via the dotnet CLI using:
dotnet new nugetconfig --output ../src/
The CLI does not seem to provide a way to add config or solution items to the file. It does provide a way for me to add packageSources items, but I'm not really interested in where my packages are coming from, but rather where they are going to.
Is this just something we need to continue to do manually, or is there something I'm missing. Can this be done through the CLI in some way (if so I haven't figured it out yet)? I want to use as much of the CLI as possible so the end trainees don't have to perform too many manual steps like "please download and copy this file to this location...", to get the desired functionality.
Please note I specifically reference this globalPackagesFolder as part of the training to show new hires how nuget operates. And they can clear out the folder without impacting the larger development environment as they are learning. In later lessons we show how sometimes files from this folder need to be manually copied to the project folders (jQuery, etc.) using ItemGroups and Targets in the project file like this:
<ItemGroup> <jQuery Include="../../../lib/nuget/jquery/3.3.1/Content/Scripts/jquery-3.3.1.js;../../../lib/nuget/jquery/3.3.1/Content/Scripts/jquery-3.3.1.min.js;../../../lib/nuget/jquery/3.3.1/Content/Scripts/jquery-3.3.1.min.map;../../../lib/nuget/jquery/3.3.1/Content/Scripts/jquery-3.3.1-vsdoc.js;"/> </ItemGroup> <Target Name="ClientSideContent" AfterTargets="AfterBuild"><Copy SourceFiles="@(jQuery)" DestinationFolder="./root/Scripts" /></Target>