locked
Is it possible to check my Razor / cshtml files at compile time? RRS feed

  • Question

  • User-1027401117 posted

    I am using web pages inside a Web Application project inside Visual Studio 2013. If it was an MVC project, I could precompile my cshtml files using the `<MvcBuildViews>true</MvcBuildViews>` switch in the csproj file. However, that does not have any effect on my Web Pages cshtml files - when I make deliberete code error in one of my cshtml file, ths build still passes fine.

    Is it possible to check my web pages Razor files at compile time?

    Sunday, June 1, 2014 5:57 AM

All replies

  • User-166373564 posted

    HI BorekBernard,

    To let you detect these errors at compile time, ASP.NET MVC projects include an MvcBuildViews property, which is disabled by default. To enable this property, open the project file and set the MvcBuildViews property to true.

    <PropertyGroup>
      <MvcBuildViews>true</MvcBuildViews>
    </PropertyGroup>

    According to your description above, you could take a look at the discussion below.

    How to compile cshtml before runtime 

    Hope it helps.

    Regards

    Wednesday, June 4, 2014 11:30 PM