17 December 2015

Turn on Compile-time View Checking for ASP.NET MVC

The .cshtml files are not natively compiled and therefore cheched for spelling mistakes at compile time. This can be changed, e.g. at build server level.

<target condition="'$(MvcBuildViews)'=='true'" name="AfterBuild">
<aspnetcompiler physicalpath="$(ProjectDir)\..\$(ProjectName)" virtualpath="temp"></aspnetcompiler>


This has been an option since 2010, not many know about it.

1 comment:

Jim Baltika said...

I personally prefer the MS RazorGenerator http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html. Take a look. This way no physical files to deploy, only *.dll