Using Nightly ASP.NET Web Stack NuGet Packages

Note: This blog has been superseded by this one – the instructions for Visual Studio 2012 and 2010 are the same.

We are very excited about the recent announcement of nightly NuGet packages being available on MyGet. This blog will show using these packages with Visual Studio 2010 but first you should be aware of the disclaimers. In short, these packages come with no guarantees and they do not substitute for the official installers which contain the official MSI and NuGet packages. And of course, don’t use your dev machine for anything important.

Prerequisites: Visual Studio 2010 and GacUtil

In contrast to compiling the code yourself, it is possible to use the nightly NuGets with ASP.NET MVC 4 Beta for Visual Studio 2010 installed so that you can use the project templates. The instructions here are for .NET 4.0 and Visual Studio 2010 only – it won’t work with Dev 11 Beta due to a conflict in System.Net.Http. Also, you do need to work with the Global Assembly Cache (GAC) so you do need the GacUtil tool for updating assemblies in the GAC.

Note: In ASP.NET MVC 4 Beta for Visual Studio 2010 we GAC’ed more than necessary and so when updating the NuGet packages you have to update the GAC as well as the GAC always wins when resolving assembly references. In the next official drop we GAC a lot less so much of this will go away.

Configuring NuGet

In order to see the nightly packages you first need to configure Visual Studio to point to the MyGet feed at

Under the Visual Studio Tools menu select Options and then Package Manager and add the feed – it should look like this:

UpdateFeedSource

Updating an ASP.NET MVC4 Web Application Project

Assume we have an ASP.NET MVC4 Web Application Visual Studio project (below we created a Web API but it should work for any of the project variants). Now, under the Visual Studio Project menu, select Manage NuGet Packages and select Updates from the MyGet feed you just added:

UpdatePackages 

Install the updates and close the window.

Updating the GAC

Before you can run the project you have to update the GAC with the new assemblies which NuGet downloaded and stuck in the packages folder which you can find in your solutions folder. You can get a view of the assembles by typing the following in the packages folder

  • dir /s /b *.dll

It should look something like this:

PackageAssemblies

The list below is the set of DLLs we GAC’ed in ASP.NET MVC 4 Beta for Visual Studio 2010. Moving forward we are GAC’ing a lot less so this will get much easier. Look for the assemblies on the list below and match them against the directory list above. Depending on which project variant you picked you may not have all of them – that’s ok.

  • System.Web.Mvc
  • System.Web.Razor
  • System.Net.Http.Formatting
  • System.Web.Http
  • System.Web.Http.WebHost
  • System.Web.Helpers
  • System.Web.WebPages.Deployment
  • System.Web.WebPages
  • System.Web.WebPages.Razor
  • System.Net.Http
  • System.Net.Http.WebRequest
  • System.Json

For each of the assemblies that match the GAC’ed list install them in the GAC using GacUtil (running as Administrator) like this:

  • GacUtil.exe -i <path to assembly in your packages folder>

For example,

GacUtil

Trying It Out

You are now ready to run your application. When running in the Visual Studio debugger you can verify that you use the new assemblies by looking at the Modules window available under the Visual Studio Debug menu. It should look something like this:

Modules 

The version numbers should correspond to the numbers used to name the folders under the packages folder we looked at above.

Have fun!

Henrik

del.icio.us Tags: Asp.net,webapi,mvc,codeplex