4

Can anyone share with me how to (or where I can find how to) install NuGet packages automatically when I create a new project based on my custom project template in Visual Studio 2010?

I am creating a new project template for a project that uses a couple NuGet packages by default. I've read the documentation on the NuGet site but this is not acceptable in that I want to reference an existing package if it's already installed in the project.

In other words, if I embed package v1 in my template (VSIX) but version 1.1 has already been installed in the solution, I want NuGet to reference version 1.1 instead of putting v1 into the solution and forcing the developer to update the package.

Is this possible? And, if so, how?

2 Answers 2

2

NuGet 1.5 now supports this feature without requiring that you build an ASP.NET MVC 3 project template.

http://blogs.msdn.com/b/marcinon/archive/2011/07/08/project-templates-and-preinstalled-nuget-packages.aspx

This supersedes the post that I wrote. :)

1
  • But if I'm reading this correctly again, we have to embed the package into the project template. Is there no way to trigger a download so that we get the latest version of the package? It's also not clear what happens if there's already a version of the package in the solution in which we are creating the new package - will the project template recognize it? What if the solution already has a newer version of the package installed? Nov 7, 2011 at 0:48
0

Check out this post here:

http://haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx

The article mentioned that the NuGet packages need to be on your machine, however this should change in the future (if it hasn't already).

2
  • You lost me. I'm not sure how the link for SharpDevelop translates to my question about Visual Studio 2010. Oct 29, 2011 at 0:42
  • Wow, reading fail! Never mind, I eventually found the article from Phil Haack - see updated answer :-) Oct 29, 2011 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.