Udostępnij za pośrednictwem


ASP.NET MVC 4 Beta to MVC RC Upgrade Instructions

The simplest way to upgrade from ASP.NET MVC 4 Beta to RC is to create a new ASP.NET MVC 4 RC project and copy all the views, controllers, code, and content files from the existing MVC 4 Beta project to the new project and then to update the assembly references in the new project to match the old project. If you have made changes to the Web.config file in the MVC 4 Beta project, you must also merge those changes into the Web.config file in the MVC 4 RC project.

To manually upgrade an existing ASP.NET MVC 4 Beta application to version 4 RC, do the following:

In both the application root web.config file, and the Views\Web.config :

In the pages\namespaces XML element, add the following element:

 <add namespace="System.Web.Optimization"/>

Update Bundling/Minification.

In the  Global.asax.cs file,  delete the following deprecated bundle code: 

 BundleTable.Bundles.RegisterTemplateBundles();

Replace that call with the following code:

 BundleConfig.RegisterBundles(BundleTable.Bundles);

Create a new ASP.NET MVC 4 RC project and copy the App_Start\BundleConfig.cs file into your Beta project. Any bundles you created for your Beta project will need to be manually converted to using the new bundle API.

From the Tools menu, select Library Package Manager and then click Package Manager Console. Enter the following command to update Bundling and Minification:

Install-Package -IncludePrerelease Microsoft.AspNet.Web.Optimization

In the Views\Shared\_Layout.cshtml file, replace the following three bundle calls:

 <link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/themes/base/css")" rel="stylesheet" type="text/css" />
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>

With the following two bundle calls:

 @Styles.Render("~/Content/themes/base/css", "~/Content/css")
@Scripts.Render("~/bundles/modernizr")
 
 Add the following markup just before the closing body tag in the In the Views\Shared\_Layout.cshtml file.
  @Scripts.Render("~/bundles/jquery")
 @RenderSection("scripts", required: false)
 

Update NuGet packages.

From the From the Tools menu, select Library Package Manager and then click Manage NuGet Packages for Solution. In the left pane of the Manage NuGet Packages dialog, select Updates. Select each package you would like to update (for example, jQuery, Modernizr and knockoutjs updates are not required, but the following should be updated:

  • ASP.NET MVC 4
  • System.Web.Http.Common
  • System.Net.Http
  • System.Net.Http.Formatting
  • ASP.NET Universal Providers
  • ASP.NET Web Pages 2 Core Razor Libraries
  • ASP.NET Web Pages 2 Core Libraries
  • ASP.NET Web API Core Libraries
  • ASP.NET Web API
  • System.Json

More on MVC 4/RC

More information can be found in the MVC 4/RC release notes.

In addition to blogging, I use Twitter to make quick posts and share links. My Twitter handle is: @RickAndMSFT