问题
I have a .NET Core 2.2 project that builds in both Debug and Release configuration just fine. However, the build fails when I try and publish the project.
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?)
I've tried cleaning the solution. Anyone else seen similar behaviour?
回答1:
Can you try it from terminal?
dotnet publish
来源:https://stackoverflow.com/questions/61590993/net-core-publish-compilation-errors