共用方式為


Using Nightly ASP.NET Web Stack NuGet Packages with Visual Studio 2012

Note: this blog uses Visual Studio 2012 but the instructions for VS 2010 are the same.

This blog describes using the nightly NuGet packages with Visual Studio 2012. Note well that the 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 2012 and GacUtil

In contrast to compiling the code yourself, it is possible to use the nightly NuGets with Visual Studio 2012 installed so that you can use the project templates.

As Web API is not in the GAC it is very simple to update – just get the nightly NuGets and you are done. For MVC and Web Pages you still need to work with the Global Assembly Cache (GAC) so you do need the GacUtil tool for updating assemblies in the GAC.

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:

UpdateFeedSource3

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). Under the Visual Studio Project menu, select Manage NuGet Packages, then select Updates from the MyGet feed you just added, and then select Include Prerelease:

PrereleasePackages

Install the updates and close the window.

Updating the GAC

For Web API you are all set – nothing else is needed! However, if you are using MVC or Web Pages then 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:

PackageAssemblies2

The list below is the set of DLLs that are GAC’ed in VS 2012. 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.Web.Helpers
  • System.Web.WebPages.Deployment
  • System.Web.WebPages
  • System.Web.WebPages.Razor

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_thumb8

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:

Modules2

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

Comments

  • Anonymous
    October 09, 2013
    I've tried this but it requires credentials for accessing www.myget.org/.../aspnetwebstacknightly. I've registered and logged in with myget.org but those credentials don't work with this feed...