How to fix NuGet package Razor runtime compilation Error?

倖福魔咒の 提交于 2021-01-06 03:44:36

问题


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

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


回答1:


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

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

See example below:

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

Found this property from this answer on a related question.



来源:https://stackoverflow.com/questions/60750571/how-to-fix-nuget-package-razor-runtime-compilation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!