Warm tip: This article is reproduced from stackoverflow.com, please click
asp.net asp.net-mvc azure-devops azure-pipelines tfs

Precompiling Asp.net MVC views on TFS Build definition

发布于 2020-04-20 09:53:28

We currently run builds on TFS. Is it possible to precompile views during TFS builds?

Questioner
Venkata Tata
Viewed
79
Andy Li-MSFT 2017-10-03 10:43

It's possible to pre-compiling the Asp.net MVC views on TFS.

You need to Extend the Visual Studio Build Process, introduce a new BuildViews target that will only execute if the MvcBuildViews property is set to true.

<Target Name="BuildViews" Condition="'$(MvcBuildViews)'=='true'" AfterTargets="Build">
  <Message Importance="normal" Text="Precompiling views" />
  <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>

Reference below article, refer to it for more information:

Turn on Compile-time View Checking for ASP.NET MVC Projects in TFS Build 2010