dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.72k stars 1.07k forks source link

dotnet new -i <PACKAGE_NAME> --nuget-source not working #11601

Open TheBoneJarmer opened 4 years ago

TheBoneJarmer commented 4 years ago

Today I started building the source of MonoGame on my desktop. And upon trying to install the generated package for project templates I get the following error:

C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(124,5): error : The local source 'C:\Users\ruben\.templateengine\dotnetcli\v3.1.201\scratch\Local' doesn't exist. [C:\Users\ruben\.templateengine\dotnetcli\v3.1.201\scratch\restore.csproj]

To give some more background info, this is what I am trying to do. I setup a local NuGet source as folder called Local, which points to C:\NuGet\Packages by using the follow command:

nuget sources add -Name Local -Source C:\NuGet\Packages

Than I cloned the repo of MonoGame and followed the instructions to compile the source. This resulted in several nuget packages which I than pushed with the following line:

nuget push **.nupkg -Source Local

All good so far. But here starts the issues. The next thing I try to do is using one of the nuget packages I pushed to the Local feed, which is MonoGame.Templates.CSharp, to install new project templates with by executing the following command:

dotnet new -i MonoGame.Templates.CSharp --nuget-source Local

This sadly results in the above error. The reason why I have to specify the source is because otherwise NuGet will use nuget.org, where packages with the same ID are located. These are the official ones from MonoGame itself and are a couple of versions behind. I managed to work around this by literally specifying the path to the .nupkg file containing the templates by executing:

dotnet new -i <PATH_TO_NUPKG_FILE>

But I prefer not to of course.

vdailly commented 4 years ago

I've encountered the same issue. dotnet new -i packagename --nuget-source the command doesn't respect the nuget.config file .

you can use: --nuget-source "C:\NuGet\Packages" --nuget-source "https://privatefeed/api/nuget/..."

I've tried to store a nuget.config file in %UserProfile%\.templateengine\dotnetcli\v3.1.201\scratch\ and specify --nuget-source nuget.config or --nuget-source Local but none works neither.

Issue remains for private nuget feeds where authentication is required (and stored in the nuget.config file).

vdailly commented 4 years ago

More this seems related to https://github.com/dotnet/templating/blob/master/src/Microsoft.TemplateEngine.Cli/Installer.cs