如何修复NuGet软件包Razor运行时编译错误? [英] How to fix NuGet package Razor runtime compilation Error?

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

问题描述

在阅读了多个答案之后(

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运行时编译错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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