Include NuGet package with project template?

May 30, 2011 at 8:15 PM

How can I automatically include a NuGet package with a project template (created using Visual Studio's Export Template Wizard)? I've seen lots of references to various packages from Microsoft teams doing so, but no instructions as to how.

I'm able to create the template, but I'm encountering issues with dependency resolution when the path to the solution root is different in the template than it is in the target solution.


For example, if the solution in the project used to create the template looks like this:

  • Solution Root
    • packages\MyPackage\lib\.....
    • TemplateProjectDir
      • TemplateProject

And the target solution looks like this:

  • Solution Root
    • packages\MyPackage\lib\...
    • TemplateProject

Then the relative paths used in the <Hint> element in the csproj file will not match up, and the newly created project won't be able to find the libraries.

Also, this doesn't actually help with including the libraries themselves - this still requires manually adding the package.


Is there a way to have all this done automatically?

May 31, 2011 at 4:24 PM

ASP.NET MVC has custom project tooling that does this. However, we're testing out a technique that might allow others to do so outside of an ASP.NET MVC project. But so far, there's no way to do this apart from building your project as an MVC 3 project. I'll be posting a blog post with details on this soon.

Jul 8, 2011 at 7:48 PM


Take a look at this post:, which describes an upcoming feature of NuGet 1.5 that enables this scenario for all project templates.

Jul 8, 2011 at 7:50 PM

That sounds perfect! I'll check it out. Thanks!