I've built an ASPNetCore 6.0 website using Visual Studio 2022 (17.0.4), everything works fine on my development machine.
I'm now trying to deploy it via a Jenkins build server. I first installed the .Net 6.0.2 SDK and ASP.NET Core Runtime 6.0.2 Hosting bundle via https://dotnet.microsoft.com/en-us/download/dotnet/6.0. Did a reboot as requested after the Hosting Bundle.
I'm now running command dotnet publish /p:Configuration=Release .\path\to\my.csproj /p:PublishProfile=FolderProfile
and I'm getting a bunch of errors such as this one:
error NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 6.0.2 supports: net6.0 .NETCoreApp,Version=v6.0)
and
error NU1202: Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0)
Also with the same error are packages Microsoft.EntityFrameworkCore.Design 6.0.2, Microsoft.EntityFrameworkCore.Proxies 6.0.2, Microsoft.EntityFrameworkCore.Relational 6.0.2, Microsoft.EntityFrameworkCore.SqlServer 6.0.2, Microsoft.EntityFrameworkCore.Tools 6.0.2
I don't understand why it is telling me that it seems to have downloaded packages that support .NETCoreApp,Version=v6.0 but wants packages that are compatible with .NETFramework,Version=v6.0. I thought the whole point with .NET 6.0 is that there is no longer any differentiation between Core and Framework, it's all the same thing?
To ensure I'm running the correct version of the tooling (checking the answer at https://stackoverflow.com/a/70251470/206852), dotnet --version
gives 6.0.200
. When running dotnet publish
the first thing it says is Microsoft (R) Build Engine version 17.1.0 ae57d105c for .NET
.
All projects in the solution are SDK style (in that in the .csproj file they contain <Project Sdk="Microsoft.NET.Sdk.Web">
or <Project Sdk="Microsoft.NET.Sdk">
, and all target net6.0 <TargetFramework>net6.0</TargetFramework>
.
Any ideas on how I can fix this?
EDIT: I noticed that a few packages are giving a slightly different error, here's the entire list of errors (I've removed the project path which is originally included at the start of each line):
error NU1202: Package Microsoft.AspNetCore.Mvc.NewtonsoftJson 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.AspNetCore.Mvc.NewtonsoftJson 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Design 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.EntityFrameworkCore.Design 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Proxies 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0).Package Microsoft.EntityFrameworkCore.Proxies 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Relational 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.EntityFrameworkCore.Relational 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.EntityFrameworkCore.SqlServer 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Tools 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.EntityFrameworkCore.Tools 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0). Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.AspNetCore.Mvc.NewtonsoftJson 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.AspNetCore.Mvc.NewtonsoftJson 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Design 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Design 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Proxies 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Proxies 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Relational 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Relational 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.EntityFrameworkCore.SqlServer 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.EntityFrameworkCore.Tools 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0) error NU1202: Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.2 is not compatible with net60 (.NETFramework,Version=v6.0) / win7-x86. Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 6.0.2 supports: net6.0 (.NETCoreApp,Version=v6.0)
In the errors in the last half of this list "win7-x86" is referenced. I have no idea why, this is a Windows Server 2012 server running on a 64-bit OS, I have installed the 64-bit version of the SDK (verified looking in Programs and Features).
CodePudding user response:
Well, after a lot of headache, I finally solved this. I did many things, so I'm not sure what was actually necessary and what was not, but I'll detail the steps here.
Firstly, I had 3 .NET core SDKs installed on the server including 6.0.200. I uninstalled all of them and rebooted. I then installed 6.0.200 again and rebooted.
I tried to rebuild again at this point and got a different error: MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
- this was weird because the SDK was definitely installed and in the right place etc etc.
This led me to https://github.com/dotnet/sdk/issues/10229 and https://github.com/dotnet/msbuild/issues/2532 which led me to create a new environment variable MSBuildSDKsPath
pointing at C:\Program Files\dotnet\sdk\6.0.200\Sdks
, it took another reboot get Jenkins to pick this up, but after that, the build started working :)