Search code examples
razorcompilationasp.net-core-mvcdotnet-cli

compile razor views in .net core


Is there a way I can compile all my razor views (to verify) any time I need? I found this doc which shows how it compiles on publish https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-2.1&tabs=aspnetcore2x.

I am looking for an option within visual studio or even better via CLI that compiles and validates all views. I did find this official razor CLI tool in preview, but no documentation: https://www.nuget.org/packages/Microsoft.AspNetCore.Razor.Tools/1.1.0-preview4-final


Solution

  • Well, you can publish any time you need. The name ‘publish’ does not mean ‘push my site to the coliseum of public opinion’ :-)

    All that it does stays local, and dotnet publish will by default create a directory under your project bin folder with, as you say, compiled views and other artefacts.