question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing a template with `dotnet new -i` from custom Nuget source not working

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ncunningcommented, Jan 31, 2019

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

0reactions
rodrigocarfercommented, Jun 4, 2020

Thanks

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! I just got it working by removing all unnecessary packages folders, .nupkg and .nuspec files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing dotnet new template not working from NuGet ...
I have a template which is packaged and deployed to an Azure Devops NuGet Feed. I can't install this template when I use...
Read more >
dotnet new install - .NET CLI
The dotnet new install command installs a template package. ... NuGet sources available for the current working directory and the sources ...
Read more >
Quickly Create Your Own .NET Code Templates and Use ...
Packaging templates. The dotnet new templating tool supports installing templates from nuget packages locally or in remote repositories.
Read more >
installation issues - Umbraco 9
Hi,. I'm having some issue with installing umbraco 9. I have added the nuget source using the command line. So far so good....
Read more >
How to Create Your .NET Project Template
Let's install it locally by running the following command in the templates-playground/templates/auth0-webapp folder: dotnet new --install . This command lets ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found