Precompile a asp.net4 mvc3 website using visual st

2020-02-26 02:28发布

问题:

What is the best way to pre-compile a asp.net4 mvc3 website with all its view files using visual studio 2010?

I'm a little confused because MS provides multiple solutions that sound very similar.

Web Deployment Projects

http://blogs.msdn.com/b/webdevtools/archive/2010/05/26/visual-studio-2010-web-deployment-projects-rtw-available-now.aspx

Web Deployment Tool

http://www.microsoft.com/download/en/details.aspx?id=25230

or can I just do all this from the default VS2010 SP1 without additional addons?

Can someone clarify?

回答1:

When you build or publish your project, the website is already compiled. Only the views are dynamically compiled. If you want your views to be compiled also, you can edit your web project file. Change this line:

<MvcBuildViews>false</MvcBuildViews>

to:

<MvcBuildViews>true</MvcBuildViews>

To be able to edit the project file within visual studio you have to unload the project first (right-click, Unload Project) and then right click the project again and choose Edit Project. When you made the change, your views will be automatically be build also. This is not something you want to do during development, build time significantly increases.