zihotki / RazorEngine.Generator.Sample

Sample project for RazorEngine Generator tool
Apache License 2.0
1 stars 1 forks source link

RazorEngine.Generator for VS 2017 #2

Open rohatsu opened 7 years ago

rohatsu commented 7 years ago

@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

zihotki commented 7 years ago

Hey, I will look into it on these weekend and will try to come up with a solution

rohatsu commented 7 years ago

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...

benosman commented 6 years ago

@rohatsu - do you happen to have any tips to get RazorEngine templates working with RazorGenerator in VS2017?

rohatsu commented 6 years ago

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:

benosman commented 6 years ago

@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.

rohatsu commented 6 years ago

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

benosman commented 6 years ago

@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.