如何强制MVC视图错误导致项目编译失败?

时间:2013-02-07 20:38:58

标签: asp.net-mvc-3 compiler-errors

目前,当我编译时,我没有在编译窗口中看到来自cshtml视图的任何错误。

只有当我打开视图时,才能看到红线下划线的问题。就是这样。

如果视图中有错误,我需要编译失败。

感谢。

1 个答案:

答案 0 :(得分:11)

在记事本中打开csproj文件,将MvcBuildViews属性更改为true。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <!-- other properties ... -->
    <MvcBuildViews>true</MvcBuildViews>
  <!-- the rest of your project file ... -->