3

I have a following problem: my custom template is on my nuget server( not an official nuget.org server).

I could not find any information about specifying the source of nuget package. For example, as it is implemented in dotnet restore -s my-custom-server.org command, where parameter -s, you can pass the source of nuget package, and the packages will be taken from this source.

How can I do the same with command dotnet new -i my_custom_template? In manual on microsoft site, it is written that you can pass physical path to the file(package) or ID of package on nuget.org server.

  • Have you searched for an answer to this at all? I found the following page, as the first result of a google search: https://learn.microsoft.com/en-gb/nuget/reference/nuget-config-file#package-source-sections – Jamie Taylor Feb 01 '18 at 12:35
  • I have already read this article. I don’t understand how it will help me to solve my problem. If you offer to use some global nuget.config on my pc, then it is not suitable. I need to distribute my custom template through my own nuget server. How can other user download this package? Does he really need to change global nuget.config? – Andrew Makarov Feb 01 '18 at 14:32
  • Any reason it has to be on any nuget server? You can have the user clone a repo and then do something like dotnet new --install .\template – Tony Ranieri Feb 01 '18 at 15:22

1 Answers1

3

According to the command documentation, there is the --nuget-source parameter, allowing to define a custom source.

For example the following command, installs the Fable-Elmish-React template from nuget.org given as an explicit Parameter. This concrete command worked for me overloading the default nuget feed, which wasn't nuget.org in my case.

By adapting the given feed here, you should be able to use any other feed.

dotnet new -i "Fable.Template.Elmish.React::*" --nuget-source https://api.nuget.org/v3/index.json

thor
  • 171
  • 1
  • 7