本文介绍了如何修复NuGet软件包Razor运行时编译错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了多个答案之后(),建议安装Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet包以获取运行时编译,我尝试了建议的解决方案但是该项目仅通过安装软件包而无需使用AddRazorRuntimeCompilation()即可获得以下错误消息:

After reading through several answers (.NET Core 3.0 - Preview 2 - Razor views don't automatically recompile on change) that recomend installing Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package to get back runtime compilation, I tried the suggested solutions but the project gets the following error message simply by installing the package without even using AddRazorRuntimeCompilation():

项目项目名称"必须提供配置值

The project "project name" must provide a value for configuration

双击错误会导致以下路径:

double clicking in the error leads to the following path:

C:\ Users .... nuget \ packages \ microsoft.aspnetcore.razor.design \ 2.2.0 \ build \ netstandard2.0 \ Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets

C:\Users....nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets

但是没有迹象表明此文件出了什么问题

But there is no indication as to what is wrong with this file

推荐答案

< RazorCompileOnBuild> false</RazorCompileOnBuild> 添加到您的.csproj文件.那应该可以让您构建项目.

Add <RazorCompileOnBuild>false</RazorCompileOnBuild> to your .csproj file. That should allow you to build the project.

您还可能需要< MvcRazorCompileOnPublish> false</MvcRazorCompileOnPublish> 才能发布到服务器.

You also might need <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> for publishing to a server.

请参见下面的示例:

<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    ...
    <RazorCompileOnBuild>false</RazorCompileOnBuild>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
    ...
</PropertyGroup>

在与此相关的问题的答案中找到了此属性.

Found this property from this answer on a related question.

这篇关于如何修复NuGet软件包Razor运行时编译错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 06:28