Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Visual Studio Project Template that already includes a Nuget Package Reference?

I want to create a Visual Studio 2010 Project Template, which is essentially a ASP.net 3.5 Webforms Application.

However, I would like to automatically add a NuGet Package Reference. I can bundle the actual nupkg with the template if needed, but I wonder if it's possible to instead run the Install-Package command to always retrieve the latest version when creating a new Project? (I can guarantee that future versions never break the template)

Is that possible? I only made small changes to Project Templates so far, so I don't know exactly where I would start. I found some stuff for MVC 3, but as said, I'm on Webforms (and .net 3.5).

like image 226
Michael Stum Avatar asked Jun 08 '11 00:06

Michael Stum


People also ask

How do I import a NuGet package into a project?

Drop your NuGet package files in that folder. Go to your Project in Solution Explorer, right click and select "Manage NuGet Packages". Select your new package source.


1 Answers

You can create a custom template for it, however it won't be fetched from the web, it'll only copy from your local disk (though maybe this will change in the future). Phil Haack wrote an article about this on his blog recently:

There are two major limitations:

  • The package must exist in the %ProgramFiles%\Microsoft ASP.NET\ASP.NET MVC 3\Packages folder. MVC 3 doesn’t go searching online for them.
  • The version attribute of the package in the element is required and is an exact match.
like image 60
Danny Tuppeny Avatar answered Oct 06 '22 09:10

Danny Tuppeny