关于.NET CORE 编译时错误:Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(79, 5): The project XXXXX must provide a value for Configuration.
此笔记记载了本人在编译.Net Core项目时遇到的
Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(79, 5): The project XXXXX must provide a value for Configuration.
的症状、排查及解决方案
环境
.Net Core版本:5.0(其他版本也适用)
编译工具:Visual Studio 2019,Rider 2021.1.3
症状
在编译项目的时候编译过程中产生如下错误Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(79, 5): The project XXXXX must provide a value for Configuration.
并终止编译。
解决方案
- 安装Nuget包
安装Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
包,可以使用命令Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
也可以在Nuget图形界面查找并安装 - 在 startup.cs 加入对应代码
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages()
.AddRazorRuntimeCompilation();
}
- 在 项目.csproj 加入节点
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
- 重新编译项目即可发现已经可以顺利编译
本文来自博客园,作者:一块白板,转载请注明原文链接:https://www.cnblogs.com/ykbb/p/15013230.html
分类:
标签:
« 上一篇: 关于Java访问SQL server的错误:The server selected protocol version TLS10 is not accepted by client preferences [TLS12]及安全套接字层(SSL)加密与 SQL Server 建立安全连接
» 下一篇: 关于.Net Core生成JSON时错误:A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32.
» 下一篇: 关于.Net Core生成JSON时错误:A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步