Xcopy deployment of Asp.Net Mvc 3
To be more precise, this entry is talking about how to deploy Asp.Net Mvc 3 web application without deploying the official 21MB installation pacakge.
Basically, to deploy an Mvc 3 web app is amazingly easy: we just need to install AspNetMVC3Setup.exe on the web server, then use MsDeploy, or just copy the binary and content to the destination folder, that’s it.
However sometimes you want to make the automation of the deployment even easier and cleaner, or, you might not be able to install the MVC3 base package on your environment. No worry, it is not that difficult.
Prerequisite
- Windows Server 2008/R2 with IIS 7.
- .Net 4.0 runtime is installed on the server.
.Net 4.0 is needed, since the Mvc 3 binaries are built from it, I haven’t tested whether it is possible to grab the code and build from .net 3.5.
And I didn’t test IIS 6.
To Deploy:
Use the MsDeploy, then publish from visual studio, it would create the web application for you automatically.
Or, just manually create the web application, then copy the folder structure to your server. Here I use the default template of Mvc3 as an example, you need to include the *.cshtml (I use Razor), *.js, css, web.config and asax file.
We are almost done, usually Mvc base assembies are in .net 4 GAC, we need to take these files to your Bin folder:
- Microsoft.Web.Infrastructure.dll
- System.Web.Helpers.dll
- System.Web.Mvc.dll
- System.Web.Razor.dll
System.Web.WebPages.Administration.dll- System.Web.WebPages.Deployment.dll
- System.Web.WebPages.dll
- System.Web.WebPages.Razor.dll
You can get them from C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies and C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies , from the box you installed MVC3, most likely it is your develop machine.
The reason why I stroke out the System.Web.WebPage.Administratration.dll is if you copy that file, you need to also copy the NuGet.Core.dll, but if none of them are available, the site can also work.
For other IIS settings like authentication, SSL and logging, etc, you can use appcmd.exe to do the automation, it is located in %windir%\System32\inetsrv
Comments
- Anonymous
March 06, 2014
and if you can't install AspNetMVC3Setup.exe on the web server then what. Most of us develop for web servers to which we have no access other than by Xcopy But if you XCopy this project after building it in release then all of the cs files are included. This is not desirable.