Installing a template with `dotnet new -i` from custom Nuget source not working
See original GitHub issueI have a template published to our own Nuget feed. I’m trying to install it with dotnet new -i
, but none of the installation methods are working, and I’m not getting any error messages either.
I’m going to show the output I get from dotnet
.
First try: try to install without specifying the Nuget source. This is expected to fail, and it gives me a proper error message, so so far so good.
$ dotnet new -i MyCustomTemplate
Restoring packages for C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj...
C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj : error NU1101: Unable to find package MyCustomTemplate. No packages exist with this id in source(s): C:\Program Files\dotnet\sdk\NuGetFallbackFolder, Microsoft Visual Studio Offline Packages
Generating MSBuild file C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\obj\restore.csproj.nuget.g.props.
Generating MSBuild file C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\obj\restore.csproj.nuget.g.targets.
Restore failed in 89.32 ms for C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj.
Usage: new [options]
Options:
-h, --help Displays help for this command.
... rest of the help message
So I tried to specify the Nuget source with --nuget-source
. This doesn’t do anything, and doesn’t print any errors.
$ dotnet new -i MyCustomTemplate --nuget-source https://acme-int.myget.org/F/private-nuget/auth/4160d2cc-1775-4542-9b8b-3f7f46ffc0c3/api/v3/index.json
Restoring packages for C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj...
Installing MyCustomTemplate 0.3.0.
Generating MSBuild file C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\obj\restore.csproj.nuget.g.props.
Generating MSBuild file C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\obj\restore.csproj.nuget.g.targets.
Restore completed in 6.65 sec for C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj.
Usage: new [options]
Options:
-h, --help Displays help for this command.
... rest of the help message
This says Installing MyCustomTemplate 0.3.0.
and there are no errors, but it actually doesn’t install it, so if I try to use it, it’s not found.
I also tried to install by specifying the local nupkg
file.
$ dotnet new -i ./MyCustomTemplate.0.3.0.nupkg
Usage: new [options]
Options:
-h, --help Displays help for this command.
... rest of the help message
This just doesn’t seem to do anything at all.
And I also tried to first add the custom Nuget feed as a source globally with the nuget
CLI, and then do the installation with dotnet new -i
.
$ nuget sources Add -Name "Custom Myget" -Source https://acme-int.myget.org/F/private-nuget/auth/4160d2cc-1775-4542-9b8b-3f7f46ffc0c3/api/v3/index.json
Package Source with Name: Custom Myget added successfully.
$ dotnet new -i MyCustomTemplate
Restoring packages for C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj...
Installing MyCustomTemplate 0.3.0.
Generating MSBuild file C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\obj\restore.csproj.nuget.g.props.
Generating MSBuild file C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\obj\restore.csproj.nuget.g.targets.
Restore completed in 421.31 ms for C:\Users\mvincze\.templateengine\dotnetcli\v2.1.400\scratch\restore.csproj.
Usage: new [options]
Options:
-h, --help Displays help for this command.
... rest of the help message
This outputs the same as the first attempt, but I still can’t find the installed template if I do dotnet new
.
What can be the reason for this, and how could I troubleshoot what’s going wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
If anyone else comes across this same issue. In my case I found that I could not have a packages folder in the content directory. Removing this prior to the nuget pack command allowed the dotnet new -i [customnuget package path] command to work
Thanks
Thanks! I just got it working by removing all unnecessary packages folders, .nupkg and .nuspec files.