Upgrade Project MVC 2 to MVC 4

1 comments

Update:


Use BC to do this. You can just compare to codelibmvc. 

Compare the web config, make sure the assembly binding looks like this:


<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>

Also, in site.csproj - make sure this is good:
{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

and this line says ver 4
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">


Also, you need to get these files from the /bin folder

c:\data\dev\web\CodelibMVC\bin\Microsoft.Web.Infrastructure.dll
c:\data\dev\web\CodelibMVC\bin\System.Web.Mvc.dll
c:\data\dev\web\CodelibMVC\bin\System.Web.Mvc.xml
c:\data\dev\web\CodelibMVC\bin\System.Web.WebPages.Deployment.dll
c:\data\dev\web\CodelibMVC\bin\System.Web.WebPages.dll
c:\data\dev\web\CodelibMVC\bin\System.Web.WebPages.Razor.dll
c:\data\dev\web\CodelibMVC\bin\System.Web.WebPages.Razor.xml


Upgrading

 

1) Install Visual Studio 2012
2) Project is up-to-date in svn (commit or update project)
3) Open project .sln in Visual Studio 2010
4) Upgrade references
a) Delete system.web.mvc from Site, SavvyMVC and SavvyCore (savvycore project might not have this reference)
b) Add back in the system.web.mvc (4.0.0.0 version there might be three of them) reference to Site and SavvyMVC
c) Set Copy Local to True for system.web.mvc in Site
5) Search for "system.web.mvc" in web.configs that have a version number, change any version numbers from 2.0.0.0 to 4.0.0.0
6) Find "bindingRedirect" in Web.config, change oldVersion 1.0.0.0 to 0.0.0.0-4.0.0.0 and newVersion to 4.0.0.0
7) Close the solution
8) Open Site.csproj in notepad or any other text editing program
9) Under ProjectTypeGuids change {F85E285D-A4E0-4152-9332-AB1D724D3325} to {E3E379DF-F4C6-4180-9B81-6769533ABE47}
10) Find another site already upgraded to MVC 4 and copy these dlls from the bin folder to your own projects bin folder.
(microsoft.web.infrastucture, microsoft.web. webpages.deployments, microsoft.web. webpages.dll, microsoft.web. razor.dll, microsoft.web. webpages.razor.xml)
11) Open .sln with Visual Studio 2012 (by doing right click open with), ignore the upgrade report that is shown.
12) Build and test the solution has no build errors
13) If error is httpantiforgerytoken, diff error.cs to codelib and get new version that doesnt use that code.

 

Deploying


1) Add the Beweb menu to Visual Studio 2012, get the import settings from I drive
2) Backup any files that are different on live (e.g Web.config, Site.csproj, ProjectName.sln)
3) Copy up to live the Web.configs and new .dll files
4) Check the live website is still working

 

 


Comments


Leave a Comment