我有一个 .NET 5 解决方案,可以在多台机器上正常构建,但在 TeamCity 构建服务器上却没有。
C:\redacted.WebAPI.csproj : error NU1202: - net5.0 (.NETCoreApp,Version=v5.0)
C:\redacted.WebAPI.csproj : error NU1202: - netcoreapp3.1 (.NETCoreApp,Version=v3.1)
C:\redacted.WebAPI.csproj : error NU1202: Package FluentValidation.AspNetCore 10.2.2 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package FluentValidation.AspNetCore 10.2.2 supports:
C:\redacted.WebAPI.csproj : error NU1202: - net5.0 (.NETCoreApp,Version=v5.0)
C:\redacted.WebAPI.csproj : error NU1202: - netcoreapp3.1 (.NETCoreApp,Version=v3.1)
C:\redacted.WebAPI.Tests.csproj : error NU1202: Package FluentValidation.AspNetCore 10.2.2 is not compatible with net50 (.NETFramework,Version=v5.0). Package FluentValidation.AspNetCore 10.2.2 supports:
C:\redacted.WebAPI.Tests.csproj : error NU1202: - net5.0 (.NETCoreApp,Version=v5.0)
C:\redacted.WebAPI.Tests.csproj : error NU1202: - netcoreapp3.1 (.NETCoreApp,Version=v3.1)
C:\redacted.IntegrationTests.csproj : error NU1202: Package Microsoft.AspNetCore.Mvc.Testing 5.0.6 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.AspNetCore.Mvc.Testing 5.0.6 supports: net5.0 (.NETCoreApp,Version=v5.0)
C:\redacted.IntegrationTests.csproj : error NU1202: Package FluentValidation.AspNetCore 10.2.2 is not compatible with net50 (.NETFramework,Version=v5.0). Package FluentValidation.AspNetCore 10.2.2 supports:
C:\redacted.IntegrationTests.csproj : error NU1202: - net5.0 (.NETCoreApp,Version=v5.0)
C:\redacted.IntegrationTests.csproj : error NU1202: - netcoreapp3.1 (.NETCoreApp,Version=v3.1)
所有项目都有 <TargetFramework>net5.0</TargetFramework>
。
dotnet
版本是 5.0.300
,在 Windows Server 2012 R2 上。 VC++ 构建工具也已更新 (MSBuild version = "16.10.0+4242f381a"
)。
这里有什么线索吗?我准备拔头发了。
编辑,.NET SDK 信息:
Version: 5.0.300
Commit: 2e0c8c940e
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.300\
Host (useful for support):
Version: 5.0.6
Commit: 478b2f8c0e
.NET SDKs installed:
1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
1.0.4 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
3.1.201 [C:\Program Files\dotnet\sdk]
5.0.203 [C:\Program Files\dotnet\sdk]
5.0.300 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]```
答案 0 :(得分:1)
发现问题。从详细日志来看,dotnet restore 似乎使用 3.1 SDK 进行包恢复,即使它是从 5.0 SDK 开始的。
原来定义了一个环境变量 MSBuildSDKsPath
,它指向 2.1 SDK。将其设置为 5.0 SDK 后,恢复工作正常。
答案 1 :(得分:0)
https://www.nuget.org/packages/FluentValidation.AspNetCore/10.2.2
由您的 CI 服务器引起的问题,而不是由 dotnet
或 .NET SDK 引起的。