Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor templates: Cannot find compilation library location for package

I ran into this error with .NET Core 2.0 and .NET Core 2.1, while using RazorLight coupled with cshtml Razor template files for FluentEmail, in an ASP.NET Core app:

"Cannot find compilation library location for package XYZ"

Where XYZ seemed to change depending on what version of .NET Core I had deployed.

The error did not present itself in my dev environment, but reared its head after deployment, when hitting any API endpoint that required FluentEmail to use the Razor template files to generate the email body.

like image 927
2Toad Avatar asked Jul 10 '18 15:07

2Toad


1 Answers

Publish-time compilation of Razor files is enabled by default. In my case, I did not need this feature, because my Razor templates were being compiled by FluentEmail at runtime. By adding <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> to the app's csproj file, publish-time compilation was disabled, and the error resolved.

Example csproj entry:

<PropertyGroup>
  <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
like image 175
2Toad Avatar answered Nov 15 '22 01:11

2Toad