我已經使用 Visual Studio 2022 (17.0.4) 構建了一個 ASPNetCore 6.0 網站,在我的開發機器上一切正常。
我現在正在嘗試通過 Jenkins 構建服務器來部署它。我首先通過https://dotnet.microsoft.com/en-us/download/dotnet/6.0安裝了 .Net 6.0.2 SDK 和 ASP.NET Core Runtime 6.0.2 托管包。在托管捆綁包之后按照要求重新啟動。
我現在正在運行命令dotnet publish /p:Configuration=Release .\path\to\my.csproj /p:PublishProfile=FolderProfile,但遇到了一堆錯誤,例如:
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)
同樣錯誤的是包 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
我不明白為什么它告訴我它似乎已經下載了支持 .NETCoreApp,Version=v6.0 但想要與 .NETFramework,Version=v6.0 兼容的包。我認為 .NET 6.0 的全部意義在于 Core 和 Framework 之間不再有任何區別,都是一樣的嗎?
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).
uj5u.com熱心網友回復:
好吧,經過一番頭疼后,我終于解決了這個問題。我做了很多事情,所以我不確定什么是真正必要的,什么不是,但我會在這里詳細說明步驟。
首先,我在服務器上安裝了 3 個 .NET 核心 SDK,包括 6.0.200。我卸載了所有這些并重新啟動。然后我再次安裝 6.0.200 并重新啟動。
此時我嘗試再次重建并得到一個不同的錯誤:MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found- 這很奇怪,因為 SDK 確實已安裝并且安裝在正確的位置等。
這導致我訪問https://github.com/dotnet/sdk/issues/10229和https://github.com/dotnet/msbuild/issues/2532這導致我創建了一個MSBuildSDKsPath指向的新環境變數C:\Program Files\dotnet\sdk\6.0.200\Sdks,它需要另一個重新啟動讓詹金斯拿起這個,但在那之后,構建開始作業:)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/443537.html
標籤:c# asp.net-core jenkins build .net-6.0
