Force Views to Build When Building an ASP.NET MVC 1.0 Solution or Project

Overview

By default, views in an ASP.NET MVC 1.0 project do not automatically build when you build the solution or project. While this may help speed up your builds, it does not help you locate compiler errors that may occur when the page is viewed in the browser, resulting in a runtime error for your user.

Solution

1. Make sure your solution is closed and everything is checked in (if using source control).

2. Locate the project file for the project that contains your .aspx views. If you are using C Sharp, it will be named [ProjectName].csproj. If you are using VB.NET, it will be named [ProjectName].vbproj. If you are using source control, such as Visual Source Safe, you will need to manually check out the file.

3. Open the project file in a plain text editor, such as notepad.exe.

4. Locate the MvcBuildViews element and change its value to "true".

  1. <Project>
  2. <PropertyGroup>
  3. <MvcBuildViews>true</MvcBuildViews>
  4. ...

5. Close the project file and check in your changes.

6. Reopen your solution. The views will now build when you build the solution or project.

kick it on DotNetKicks.com