Compile-Time Checking of ASP.NET Views
Overview
¶
If you've ever refactored a view model for an ASP.NET site, you're aware that doing so can break the Razor view(s) that the view model is based upon. Furthermore, you won't discover this until the view is invoked at run-time. This article describes how to avoid this by forcing the Razor views to be build at compile-time, thus revealing any issues.
Credits
¶
Thanks to Jeff Polakiewicz for showing me this.
Adapted from
https://blogs.msdn.microsoft.com/jimlamb/2010/04/20/turn-on-compile-time-view-checking-for-asp-net-mvc-projects-in-tfs-build-2010/
Procedure
¶
1. Unload Web project
2. Edit Web Project
3. Add the
MvcBuildViews
line
<PropertyGroup> . . . <MvcBuildViews>true</MvcBuildViews> . . . </PropertyGroup>