I get RazorLightException when trying to call lib that contains razor templates from console application
See original GitHub issueException text:
RazorLight.RazorLightException: 'Can't load metadata reference from the entry assembly. Make sure preserveCompilationContext is set to true in buildOptions section of project.json or in *.csproj file'
Here is the solution with isolated case: https://1drv.ms/u/s!AuXjDEud3Cas10ihf9jpraKC316w
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Razor templates: Cannot find compilation library location ...
Publish-time compilation of Razor files is enabled by default. In my case, I did not need this feature, because my Razor templates were ......
Read more >RazorLight
RazorLight. Use Razor to build templates from Files / EmbeddedResources / Strings / Database or your custom source outside of ASP.NET MVC.
Read more >Razor Email Template Parsing From a .NET Core Console ...
So how do you run Razor template parsing outside of an MVC Web App in .NET Core? I found myself having to answer...
Read more >Walkthrough: Creating an HTML Email Template with ...
Therefore, I try to make my folder and/or view names clearly unique like “ConfirmAccountEmail.cshtml” which is unlikely to have a matching route ...
Read more >Razor file compilation in ASP.NET Core
Learn how compilation of Razor files occurs in an ASP.NET Core app.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Add
<PreserveCompilationContext>true</PreserveCompilationContext>to the csproj, worked for me!@ossaltu, I suspect that you didn’t clean the project before rebuilding and trying that again. It was an issue for myself. I’ve just created the PR to add this warning to README.