0

Our solution contains few doesens of web projects and thousands of razor views. My concirn is that the razor vies are slowing down the IDEs (namely the Rider IDE).

In my understanding, at runtime, Razor views are compiled to cs.

Is there a technology to pre-generate cs diring design time, similar to resx files backed by cs code, so the solution analysis is csharp only, and there is no runtime compilation penalty too?

George Polevoy
  • 7,450
  • 3
  • 36
  • 61
  • Possible duplicate of https://stackoverflow.com/questions/49028212/precompile-asp-net-views-with-ms-build –  Jan 29 '19 at 22:02
  • @Amy I'm not sure if it is the right duplicate as OP is asking for asp.net-core and suggested duplicate (and similar posts like https://stackoverflow.com/questions/13482007/how-to-compile-cshtml-before-runtime) deal with regular ASP.Net… possibly applies to both so. – Alexei Levenkov Jan 29 '19 at 22:06
  • @AlexeiLevenkov Aye, I wasn't sure, so didn't vote to close, instead opting to comment for feedback just like that. –  Jan 29 '19 at 22:07
  • The question is about _design time_ compilation, not _precompilation during build_ like the suggested duplicate. – George Polevoy Jan 30 '19 at 07:51

1 Answers1

0

It depends on the version on ASP.NET Core. The documentation is here, just select the appropriate ASP.NET Core version in the top left.

To sum it up:

ASP.NET Core 2.1+

Views are precompiled by default

ASP.NET Core 2.0

If you're targetting .NET Core, views are precompiled by default.

If you're targetting the full Framework, install the Microsoft.AspNetCore.Mvc.Razor.ViewCompilation NuGet package.

ASP.NET Core 1.1

Install the Microsoft.AspNetCore.Mvc.Razor.ViewCompilation NuGet package and set the MvcRazorCompileOnPublish property to true in the project file.

ASP.NET Core 1.0

That article doesn't exist for 1.0, so my guess is that it's not supported.

Community
  • 1
  • 1
Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84