Name: MvcPrecompilation
Owner: ASP.NET
Description: Tooling that allows compilation of MVC Razor views as part of build and publish. NOTE: future work on Razor compilation is now being handled in the Razor repo. See the README for more details.
Created: 2016-08-19 00:36:17.0
Updated: 2018-05-21 16:43:02.0
Pushed: 2018-05-23 22:36:35.0
Size: 531
Language: C#
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The Razor syntax provides a fast, terse, clean, and lightweight way to combine server code with HTML to create dynamic web content. This repo contains tooling that allows compilation of MVC Razor views as part of build and publish.
Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
packageMicrosoft.AspNetCore.Mvc.Razor.ViewCompilation
package is added by Microsoft.AspNetCore.All
and you do not need to explicitly reference it.Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
in your project:mGroup>
ackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.1" />
emGroup>
View compilation as part of publishing is enabled by default if you're referencing the Web SDK (Microsoft.NET.Sdk.Web
) that ships with .NET Core 2.0 or later versions. For older versions, add the MvcRazorCompileOnPublish
property to your project:
pertyGroup>
vcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
opertyGroup>
Alternatively, you may wire up the MvcRazorPrecompile
target to a build event:
rget
Name="PrecompileRazorViews"
AfterTargets="Build"
DependsOnTargets="MvcRazorPrecompile" />
Some aspects of view compilation can be configured by editing the project:
MvcRazorCompileOnPublish
: Setting this to false
turns off all functions of view compilation that are enabled as part of publishing.
MvcRazorExcludeViewFilesFromPublish
: Enabling MvcRazorCompileOnPublish
prevents .cshtml files from being published. This option disables this behavior.
Note: ASP.NET Core Mvc does not support updateable precompiled views. Any modifications to published cshtml files will be ignored if a precompiled view is discovered for that path.
MvcRazorExcludeRefAssembliesFromPublish
: Enabling MvcRazorCompileOnPublish
causes the target to prevent the refs
directory from being published. This option disables this behavior.
Note: Setting this option is useful if your application is using a mix of precompiled and runtime compiled views.
MvcRazorFilesToCompile
: An item group that specifies view files to compile. By default this includes all .cshtml files marked as content.
This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the Home repo.