GithubHelp home page GithubHelp logo

isabella232 / mvcprecompilation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aspnet/mvcprecompilation

0.0 0.0 0.0 590 KB

[Archived] Tooling that allows compilation of MVC Razor views as part of build and publish. Project moved to https://github.com/aspnet/AspNetCore

License: Other

Batchfile 0.30% PowerShell 3.97% Shell 5.52% C# 82.43% HTML 7.78%

mvcprecompilation's Introduction

ASP.NET Core MVC Precompilation [Archived]

This GitHub project has been archived. Ongoing development on this project can be found in https://github.com/aspnet/AspNetCore.

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.

Installation and usage

Referencing the Microsoft.AspNetCore.Mvc.Razor.ViewCompilation package

  • If you're targeting ASP.NET Core 2.0 or higher on netcoreapp2.0, a reference to the Microsoft.AspNetCore.Mvc.Razor.ViewCompilation package is added by Microsoft.AspNetCore.All and you do not need to explicitly reference it.
  • For desktop targeting projects or projects targeting ASP.NET Core 1.x, add a package reference to the appropriate version of Microsoft.AspNetCore.Mvc.Razor.ViewCompilation in your project:
<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.1" />
</ItemGroup>

Enabling view compilation

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:

<PropertyGroup>
  <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
</PropertyGroup>

Alternatively, you may wire up the MvcRazorPrecompile target to a build event:

 <Target 
    Name="PrecompileRazorViews" 
    AfterTargets="Build"
    DependsOnTargets="MvcRazorPrecompile" />

Options

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.

mvcprecompilation's People

Contributors

pranavkm avatar aspnetci avatar ryanbrandenburg avatar ntaylormullen avatar rynowak avatar mkartakmsft avatar juntaoluo avatar ajaybhargavb avatar kichalla avatar mikaelm12 avatar pakrym avatar natemcmaster avatar haok avatar davidfowl avatar dougbu avatar mikeharder avatar analogrelay avatar tratcher avatar tuespetre avatar eilon avatar jkotalik avatar phrohdoh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.