Installing NuGet packages from automation?

Jul 4, 2011 at 11:12 AM

Hello,

I am trying to create project templates that automatically download the latest packages (from a corporate nuget server). For this, I implement the IWizard interface and I use a custom xml file similar to "packages.config" which has some additional feed info (so you can decide which feed to use for the packages).

Now my question is: how can I add a nuget package from the shell or via automation?

Thanks in advance.

Jul 8, 2011 at 7:50 PM

Geertvan,

Not sure what the context of your specific question is. However, take a look at the following blog post that describes an upcoming feature of NuGet 1.5 that's similar to what you want: http://blogs.msdn.com/b/marcinon/archive/2011/07/08/project-templates-and-preinstalled-nuget-packages.aspx. You could look at the code for inspiration.

Jul 9, 2011 at 3:06 PM

Great, thank you very much for your reply.

I have written my own wizard template that is able to install packages, but also allows packages to come from different sources (so you can get prism from official source, and some custom libraries from a company source). Then, you can also add packages to specific projects (like $projectname$.Web for a generated web project for Silverlight).

I hope I can convert it to use the NuGet code in the end, that would mean less code to maintain in the future. Thanks for the information so far.

Best regards,

Geert

Jul 8, 2014 at 2:14 PM
GeertvanHorrik wrote:
Hello, I am trying to create project templates that automatically download the latest packages (from a corporate nuget server). For this, I implement the IWizard interface and I use a custom xml file similar to "packages.config" which has some additional feed info (so you can decide which feed to use for the packages). Now my question is: how can I add a nuget package from the shell or via automation? Thanks in advance.
Hi Geert,
Would it be possible that you can show how you implemented the wizard which consumes the NuGet packages from a feed? I want to provide Visual Studio templates which can download NuGet packages from a private NuGet feed. Unfortunately the Preinstalled NuGet Package feature doesn't allow to download packages from feeds.

Thanks
pascal
Jul 8, 2014 at 2:17 PM
It's been a long time, and have not used it with NuGet and private feeds. Have you configured the private feed before using the project template?
Jul 8, 2014 at 2:22 PM
Yes, the feed is configured in Visual Studio. But the Preinstalled NuGet Package feature doesn't support downloading NuGet packages from a feed:
A frequent question is why not support downloading the nupkg files directly from http://nuget.org. We decided not to support such an option because users expect project templates to instantiate quickly and downloading files from the internet would slow things down.
Therefore I assume I need to create my own solution which should achieve more or less the same as your solution (Implement the IWizard interface, use a custom xml file similar to "packages.config" with some additional feed info).

I'm not sure how to implement the NuGet stuff in the wizard though.
Jul 8, 2014 at 2:24 PM
In new project wizards, I simply open a readme.txt where I explain the user which packages to install. That is easiest and isn't too much work for the end-user as well.
Jul 8, 2014 at 2:26 PM
OK, Thanks