Eduardo Molteni
Eduardo Molteni

Reputation: 39413

Is it possible to upgrade to MVC4 using a NuGet Package?

I've read the list to upgrade a site to MVC4 here http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806 and after that start looking for a package that can do that (You know, I'm lazy)

I found that there are some MS packages with the DLLs inside, but none that only change the web.config, the references, etc.

That let me wonder if NuGet is able to do all the transformations or not.

Do you know if it's possible to upgrade to MVC4 using a NuGet Package?

Upvotes: 2

Views: 1028

Answers (2)

Eduardo Molteni
Eduardo Molteni

Reputation: 39413

Just tried to make the package myself, and the problem is that you can't delete/replace entries on web.config or in the project file, you can only add.

Off to make an exe...

Edit Made this command line exe that does the transformations replacements in web.config, project.csproj and views\web.config https://gist.github.com/3560580 Enjoy!

Upvotes: 2

Martin Devillers
Martin Devillers

Reputation: 18002

Unfortunately, no, some manual steps are involved:

Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4

To upgrade and existing ASP.NET MVC 3 Project to ASP.NET MVC 4, one need to take care of following points:

  1. In all web.config, including one in root folder and Views folder, change assembly version 3.0.0.0 to 4.0.0.0 for System.Web.Mvc and 1.0.0.0 to 2.0.0.0 for System.Web.WebPages, System.Web.Helpers, System.Web.WebPages.Razor.
  2. Change appSettings value for key "webPages:Version" to "2.0.0.0". Apart from that also add new appSettings key named "PreserveLoginUrl" with "true" as a value.
  3. Now remove all reference to MVC 3.0 assembly and Webpages 1.0 assembly. And add a reference to MVC 4.0 assembly and Webpages 2.0 assembly.
  4. If you are using any third party assembly built with previous versions of MVC then do not forget to configure bindingredirect in root web.config as mentioned here.
  5. Finally one more step is to change project type to MVC 4 from MVC 3. For that unload project by right clicking in solution explorer and select edit ProjectName.csproj file. Now Locate the ProjectTypeGuids element and replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}. Now save changes and reload the project.

Upvotes: 3

Related Questions