RazorEngineCore icon indicating copy to clipboard operation
RazorEngineCore copied to clipboard

Compile templates at build-time

Open ScottishTapWater opened this issue 4 years ago • 2 comments

It seems as though compiling the templates AOT is supported and that they can be saved to and loaded from disk.

Is there any way to do this automatically at build time?

ScottishTapWater avatar Nov 15 '22 10:11 ScottishTapWater

Hi, im not sure VS can handle it by its own like it does with asp.net cshtml files. I would go with one of these:

  • put your template compilation logic in one of classes and schedule its execution after build is complete
  • sounds like a good case for new C# code generators. See GeneratedRegex as reference

adoconnection avatar Nov 19 '22 15:11 adoconnection

Another reference for implementing: MiniRazor.CodeGen

jr01 avatar Feb 18 '23 14:02 jr01