Check for razor errors during build

前端 未结 3 1470
一向
一向 2020-12-04 17:30

Is there a way for Visual Studio (I\'m using 2010) to find errors within razor views during builds, in the same way as other code in a C# project would?

It\'s just a

3条回答
  •  囚心锁ツ
    2020-12-04 18:04

    Building views takes a while and the extra 10+ seconds to do a debug build can get annoying fast, so I usually only set the MvcBuildViews to true on release type build configurations. That way, if you have a build server it will catch the error for you, or you can manually run a release build every now and then to check your views.

    I don't think order matters for PropertyGroup elements, but for a more complete example i included elements above and below the MvcBuildViews element.

    
        Debug
        AnyCPU
        ...
        v4.6.1
        false
        false
        ...
    
    
    
        ...
        prompt
        true
        4
        ...
    
    

    The MvcBuildViews element in the top PropertyGroup was added by VS on project creation, the build configuration specific one (bottom PropertyGroup) i added manually

提交回复
热议问题