无法在管道中构建 .Net 5

wal*_*eed 9 .net azure azure-devops azure-pipelines

两周前我使用 .Net 5 RC2 创建了一个新的解决方案。我已将其升级到新版本 (5.0.0)。我正在尝试创建一个标准的 ASP.Net 管道来构建它,代理池是 Azure Pipelines,代理规范我已经尝试了 windows-2019 和 vs2017-win2016。两者都给出与下面相同的错误 为什么它试图使用 2.1?

Checking compatibility for System.Composition.AttributedModel 1.0.31 with .NETFramework,Version=v5.0 (win7-x86).
Checking compatibility for System.Composition.Runtime 1.0.31 with .NETFramework,Version=v5.0 (win7-x86).
Checking compatibility for System.Composition.TypedParts 1.0.31 with .NETFramework,Version=v5.0 (win7-x86).
Incompatible packages: 4
Committing restore...
Generating MSBuild file D:\a\1\s\XXX\obj\XXX.csproj.nuget.g.props.
Generating MSBuild file D:\a\1\s\XXX\obj\XXX.csproj.nuget.g.targets.
Writing lock file to disk. Path: D:\a\1\s\XXX\obj\project.assets.json
Writing cache file to disk. Path: D:\a\1\s\XXX\obj\XXX.csproj.nuget.cache
Restore failed in 38.96 sec for D:\a\1\s\XXX\XXX.csproj.
NuGet Config files used:
D:\a\1\Nuget\tempNuGet_3.config
Feeds used:
https://api.nuget.org/v3/index.json
Installed:
71 package(s) to D:\a\1\s\XXX\XXX.csproj
##[error]The nuget command failed with exit code(1) and error(NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
Errors in D:\a\1\s\XXX\XXX.csproj
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Tools 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Tools 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Relational 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
NU1202: Package Microsoft.EntityFrameworkCore.Design 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package Microsoft.EntityFrameworkCore.Design 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1))
##[error]Packages failed to restore
Finishing: NuGet restore ```
Run Code Online (Sandbox Code Playgroud)

wal*_*eed 13

它使用的是旧版本的 Nuget。

我在还原之前将其更改为 5.x,现在可以使用了。

流水线yaml

- task: NuGetToolInstaller@1
          inputs:
              versionSpec: 4.x.x
Run Code Online (Sandbox Code Playgroud)

编辑:然后遇到了构建不起作用的问题,因为 MSBuild 16.8 尚未发布。改为 dotnet build 并将 Use Dotnet 5 任务放在它之前

  • 这对我也有用。请将此标记为正确。 (3认同)
  • 或者只使用 dotnet cli 恢复 cmd。为我工作 (2认同)