ASP.NET MVC:如果视图有错误,如何发出编译错误信号?

Ric*_*ald 6 compiler-construction asp.net-mvc

我的观点有误.只有在Visual Studio中打开视图时才会看到这些错误.

我想在编译时看到错误,而不是在执行时.

是否存在获得此行为的方法?

Sco*_*ott 4

您可以手动更新 .csproj 文件并添加一个<MvcBuildViews>true</MvcBuildViews>将随时编译视图的文件。

这是我在谷歌上搜索的链接,您也可以找到其他链接。

编辑:如果速度太慢,请尝试仅将构建设置为发布,编辑 csproj 文件,执行以下操作;有关更多详细信息,请参阅AspNetCompiler的文档。

<!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   Other similar extension points exist, see Microsoft.Common.targets.
   -->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
    <AspNetCompiler VirtualPath="Temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
Run Code Online (Sandbox Code Playgroud)