首页 > 解决方案 > .NET Core 发布编译错误

问题描述

我有一个 .NET Core 2.2 项目,它在调试和发布配置中都构建得很好。但是,当我尝试发布项目时,构建失败。

Startup.cs(26,16): Error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?) Startup.cs(35,39): Error CS0246: The type or namespace name 'IServiceCollection' could not be found (are you missing a using directive or an assembly reference?) Startup.cs(29,24): Error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?) Controllers\ConsentController.cs(37,13): Error CS0246: The type or namespace name 'ILogger<>' could not be found (are you missing a using directive or an assembly reference?) Controllers\ConsentController.cs(30,26): Error CS0246: The type or namespace name 'ILogger<>' could not be found (are you missing a using directive or an assembly reference?)

我试过清洗溶液。其他人看到过类似的行为吗?

标签: c#.net-corebuildpublish

解决方案


从终端试试这个:

dotnet publish

推荐阅读