剃刀模板:找不到包的编译库位置 [英] Razor templates: Cannot find compilation library location for package

查看:98
本文介绍了剃刀模板:找不到包的编译库位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 RazorLight 时,.NET Core 2.0和.NET Core 2.1出现了此错误a>在ASP.NET Core应用中与 FluentEmail 的cshtml Razor模板文件结合在一起:

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:


找不到包 XYZ 的编译库位置

XYZ 似乎在哪里更改,具体取决于我部署的.NET Core版本。

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

该错误并未出现在我的开发环境中,而是在部署后遇到任何需要FluentEmail使用Razor模板文件生成电子邮件正文的API端点时抬起头来。

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.

推荐答案

默认情况下启用Razor文件的发布时编译。就我而言,我不需要此功能,因为我的Razor模板是在运行时由FluentEmail编译的。通过将< MvcRazorCompileOnPublish> false< / MvcRazorCompileOnPublish> 添加到应用程序的csproj文件中,可以禁用发布时编译,并且可以解决错误。

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.

csproj条目示例

<PropertyGroup>
  <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>

这篇关于剃刀模板:找不到包的编译库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆