'How to precompile an asp.net web application with msbuild 16 and above?
The current state of affairs in our build:
- We are building locally with a shared bin directory, just like a CI server build.
- As a result web applications are published into
$OutDir\_PublishedWebsites\<ProjectName> - We have manual implementation of the target to build the Asp.Net views just for the sake of validating them. It is not precompiling.
Here is the target:
<Target Name="Build"
DependsOnTargets="ResolveProjectReferences"
Condition="$(MvcBuildViews) != False And '$(MasterProject)' != '' And '$(MasterAsmName)' != ''"
Inputs="@(MvcBuildViewsInput)"
Outputs="$(MvcBuildViewsOutput)">
<PropertyGroup>
<WebProjectOutputDir>$(OutDir)_PublishedWebsites\%(ProjectReference.Filename)</WebProjectOutputDir>
</PropertyGroup>
<Message Text="Running AspNetCompiler for $(WebProjectOutputDir)" Importance="High" />
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
<WriteLinesToFile File="$(MvcBuildViewsOutput)" Lines="@(MvcBuildViewsInput)" Overwrite="True"/>
</Target>
This is, of course, an incomplete example, but it shows that we have our own ad-hoc implementation building the views to verify.
I would like to precompile the views and deploy them alongside the other binaries. Ideally, I would like to use the standard build targets and dump our ad-hoc target, but if it is too much pain, I am OK with the ad-hoc implementation.
What are the most recent instructions on the subject? I do not care about pre VS 2019.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
