addrazorruntime编译导致部署问题



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

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?)

我找到了一个答案在这里如何修复'IMvcBuilder'不包含'AddXmlDataContractSerializerFormatters'但是,在安装了建议的MVC格式化程序包之后,问题仍然存在。

我能够部署的唯一方法是注释掉我的启动类

中的以下行
var builder = services.AddRazorPages();
if (Env.IsDevelopment())
{
builder.AddRazorRuntimeCompilation();
}

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

您需要安装Microsoft.AspNetCore.Mvc.Razor。运行时编译,但不是最新版本。兼容。net Core 3.x.

Package microsoft . aspnetcore . mvc . razor . runtime compilation3.1.19