views:

372

answers:

4

Can I use the Copy Web Site tool in Visual Studio 2008 to deploy MVC application to my hosting server? However, the Web Site menu doesn't even show up in Visual Studio with MVC project opened. What's the best practice to deploy MVC application? Thanks.

+11  A: 

ASP.NET MVC isn't a web site it's a Web application. You need to Deploy it, or just build it then copy it.

Also depending on your hosting company, they may not have the System.Web.MVC assembly available to you.

So you'll need to deploy that as well in your bin directory. You can get it there by going to references, selecting System.Web.MVC. Right click -? Properties. Then Copy Locally.

EDIT: [Including extra comments from below just in case anyone misses it] you need to do an extra step prior publishing the web application. You need to set the copy local attribute to true to the following references System.Web.Mvc, System.Web.Routing and System.Web.Abstractions. If you want you can go directly to the official documentation.

Jack Marchetti
+1 was going to add that. but may as well consolidate this answer. might add that wildcarding may need to be turned on for site if hosting is using IIS6
dove
Also, for an explanation of the differences between a "web site" and a "web application", see: http://stackoverflow.com/questions/398037/asp-net-web-site-or-web-application
Eric King
You need to reference more than one assembly. They also have an attribute called copy local that saves you from having to manually copy assemblies to your bin folder. Please see my comment in dove's answer, which I also believe is the best one for this question.
Raúl Roa
+1  A: 

Right click, publish. If you want the very very simple answer.

The best practice is a very wide question that takes in build scripts, tests, etc.....

dove
Adding to your "simple" answer, you need to do an extra step prior publishing the web application. You need to set the copy local attribute to true to the following references System.Web.Mvc, System.Web.Routing and System.Web.Abstractions. If you want you can go directly to the official documentation. http://msdn.microsoft.com/en-us/library/dd410407.aspx
Raúl Roa
@Raul correct, however i'm bowing out to JackM's answer above, who notes this. thanks though.
dove
+1  A: 

Best practice is definitely to have a build script that automates the building, testing and deployment process so all you have to do is run a batch file or command to run the whole thing. We do that very successfully here using NAnt to build, test, check code coverage and deploy to test environment and production environment.

It saves an incredible amount of time not having to remember what files need copied, where they go and what configuration changes need made once deployed.

Chris Conway
A: 

I'm very happy using the now RTW Web Deployment Tool (http://www.iis.net/extensions/WebDeploymentTool). From Visual Studio 2008 I Publish the web application locally to stage the content and then use the Web Deployment Tool to synchronize with the host server.

SevenCentral