Monday, December 3, 2012

ASP.NET MVC: Compile your views up front

For a project I’m doing we had to start a large refactoring round. Therefore it would be useful to get compiler errors on our ASP.NET MVC Views too. Otherwise we had to go through all the screens our self to detect problems.

Luckily ASP.NET MVC offers this feature out-of-the-box:

  1. Unload your ASP.NET MVC project by right right clicking the project on the solution explorer in VS and choosing unload project
  2. Right click on the csproj file name and choose Edit.
  3. Somewhere in the csproj file you’ll find the following line:

  4. Change the MvcBuildViews value from false to true.

  5. Save the file and reload your project.

From this moment on the views are compiled too each time you build your project.

No comments: