次の方法で共有


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

Comments

  • Anonymous
    April 29, 2012
    Do you have to update the GAC? Can you not bin deploy the assemblies instead?

  • Anonymous
    April 29, 2012
    In the next drop Web API will be entirely out of the GAC. Razor has a tooling requirement for being in the GAC but we want to minimize it. Generally we don't want to be in the GAC.

  • Anonymous
    April 30, 2012
    Nice!

  • Anonymous
    May 01, 2012
    What about performance(not putting assembly in GAC)?

  • Anonymous
    May 02, 2012
    We need Web-Api xnext. thanks.

  • Anonymous
    May 06, 2012
    Do you think you could also start pushing symbols to the repository at SymbolSource.org, that is automatically created for you by MyGet.org? :) Push URL should be visible in your feed details page.

  • Anonymous
    May 07, 2012
    Cheap script to update GAC after updating packages: gist.github.com/2628283 My gacutil.exe.config is messed up (all nulls ????) so I haven't tested it yet.  If I find bugs after fixing gacutil, I'll update it :)

  • Anonymous
    May 09, 2012
    I'm getting the following error with the code from last night: {"Method not found: 'System.Web.Http.Services.DefaultServices System.Web.Http.HttpConfiguration.get_Services()'."} This is occuring calling the UpshotContext() and it's also occuring when trying to override the default json formatter in the global.asax. What do I need to change to make this work? thanks!

  • Anonymous
    May 26, 2012
    nice article.first  i got errors but after using your tips i resolve them thanks for sharing.

  • Anonymous
    October 15, 2012
    I'm getting an error : Compiler Error Message: CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) Can't find why....