AddRazorRuntimeCompilation 导致部署问题

And*_*rew 5 web-deployment

当我尝试部署我的项目时,它失败并显示以下消息:-

Startup.cs(75,25): error CS1061: 'IMvcBuilder' does not contain a definition for 'AddRazorRuntimeCompilation' 
and no accessible extension method 'AddRazorRuntimeCompilation' accepting a first argument of type 'IMvcBuilder' 
could be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

我在这里找到了答案How to fix 'IMvcBuilder' does not contains aDefinition for 'AddXmlDataContractSerializerFormatters'但是在安装建议的 MVC 格式化程序包后问题仍然存在。

我能够部署的唯一方法是在我的启动类中注释掉以下几行

var builder = services.AddRazorPages();
if (Env.IsDevelopment())
{
    builder.AddRazorRuntimeCompilation();
}
Run Code Online (Sandbox Code Playgroud)

也许我需要更新部署服务器上的某些内容?这是该组织的第一个 DotNet Core 3.1 应用程序

Cam*_*llo 8

您需要安装 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation,但不是最新版本。与 .Net Core 3.x 兼容的东西。

例如

包 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 3.1.19