Open rohatsu opened 7 years ago
Hey, I will look into it on these weekend and will try to come up with a solution
Thanks for following up, one of our guys sat down a while back and moved us over to RazorGenerator, there were some differences in generated code, for example around helpers, but we've managed to work around and are happy to stick with it...
@rohatsu - do you happen to have any tips to get RazorEngine templates working with RazorGenerator in VS2017?
Sure, in our case after changing Custom Tool on our views to RazorGenerator we had to do two more things to get them to compile correctly:
Namespace: RohatsuWebApp.Templates GeneratePrettyNames: true Generator: Template
var config = new RazorEngine.Configuration.TemplateServiceConfiguration
{
EncodedStringFactory = new RawStringFactory(),
...
The above was only for non-MVC .cshtml templates, MVC views we already had on RazorGenerator.
@rohatsu - Many thanks for sharing that ! those instructions worked for me and now the templates get compiled.
However, I am currently using ResolvePathTemplateManager
to lookup the template files and having the compiled versions makes no difference, the templates used are still from the file.
Do you use a trick to get RazorEngine to execute a precompiled template?
I looked into creating a custom TemplateManager
for this purpose based on the code in this RazorEngine.Generator.Sample repo, but while it almost works - changes to RazorEngine now mean you can't return a compiled template from the Resolve()
function. So currently I'm looking at creating a custom CachingProvider
instead, which seems like it may work.
Yes we are using both a custom CachingProvider and a custom TemplateManager to pre-load everything at startup, take a look at our RFRazor.cs
@rohatsu - thank you once again! :)
That is pretty much the approach I had taken, and had proof of concept working yesterday. Yours is a lot more polished of course, so I will do some refactoring of mine.
@zihotki Vasili,
We're big fans of RazorEngine.Generator custom tool for VS 2015. I was wondering if you're planning to update it for VS 2017, or if you don't have the time, perhaps open source the code so we could do it ourselves? We'd love to move over to the new VS but lack of the custom tool this is blocking us...
Many thanks,
piotr & rohatsu team