MVC Compiled Views MVC Compiled Views

Big old pain in the arse when you get a runtime error from a view, more so if its then in the build server;

Simple solution though; pop open your UI/Web project (csproj) file in an editor of your choice. Check if it already contains an false tag (if it has set it to true)

If your missing it; add it as follows…

Find the That contains the following entries…


and simply add


At the end of the file, uncomment the <Target Name="AfterBuild" section of the configuration. This should resemble…

<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />

For extra points, ensure that EnableUpdatable is set to false, or the views wont be pre-compiled.


Why this isn't just a project-property option rather than more xml trawling is anyone's guess.


Does Not Work With Umbraco (up to and including 6)

Chris McKee

Chris McKee

Software Engineer, Web Front/Backend/Architecture; all-round tech obsessed geek. I hate unnecessary optimism