Azure DevOps:迁移到 .NET Core 3.0 后管道中断



我有一个包含多个.NET Standard 2.0,.NET Standard 2.1,.NET Core 3.0和完整.NET Framework 4.8项目的解决方案。管道如下所示:

pool:
name: Azure Pipelines
demands:
- msbuild
- visualstudio
variables:
BuildPlatform: 'any cpu'
BuildConfiguration: 'release'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.0'
inputs:
version: 3.0.100
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 4.9.1'
inputs:
versionSpec: 4.9.1
checkLatest: true
- task: NuGetCommand@2
displayName: 'NuGet restore'
- task: VSBuild@1
displayName: 'Build solution ***.sln'
inputs:
vsVersion: 16.0
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
projects: '**/*tests.csproj'
- task: PublishSymbols@2
displayName: 'Publish symbols path'
inputs:
PublishSymbols: false

安装正确的 SDK 版本后,管道将运行dotnet restore以下载 .NET 标准和 .NET Core 项目使用的所有 NuGet 包。之后,它将安装 NuGet 并使用它来还原整个 .NET Framework 项目使用的 NuGet 包。

但是,迁移到 .NET Core 3.0 后,NuGet 还原失败,并显示以下错误:

[错误] nuget 命令失败,退出代码 (1( 和错误 (NU1202:包 Microsoft.EntityFrameworkCore.SqlServer 3.0.0 与 netcoreapp3.0 (.NETCoreApp,版本=v3.0(。软件包Microsoft.EntityFrameworkCore.SqlServer 3.0.0支持:netstandard2.1(.NETStandard,版本=v2.1(

NU1202:程序包 Microsoft.EntityFrameworkCore.Tools 3.0.0 与 netcoreapp3.0 (.NETCoreApp,版本=v3.0(。软件包 Microsoft.EntityFrameworkCore.Tools 3.0.0 支持:netstandard2.1 (.NETStandard,版本=v2.1( NU1202:程序包 Microsoft.EntityFrameworkCore.Relational 3.0.0 与 netcoreapp3.0 (.NETCoreApp,版本=v3.0(。Package Microsoft.EntityFrameworkCore.Relational 3.0.0 支持:netstandard2.1 (.NETStandard,版本=v2.1( Errors in d:\a\1\s\Pagesp.ChaveMovel.AspNetCore.Site.Identity.v2\Pagesp.ChaveMovel.AspNetCore.Site.Identity.v2.csproj NU1202:程序包 Microsoft.EntityFrameworkCore.SqlServer 3.0.0 与 netcoreapp3.0 (.NETCoreApp,版本=v3.0(。软件包Microsoft.EntityFrameworkCore.SqlServer 3.0.0支持:netstandard2.1(.NETStandard,版本=v2.1( NU1202:程序包 Microsoft.EntityFrameworkCore.Tools 3.0.0 与 netcoreapp3.0 (.NETCoreApp,版本=v3.0(。软件包 Microsoft.EntityFrameworkCore.Tools 3.0.0 支持:netstandard2.1 (.NETStandard,版本=v2.1( NU1202:程序包 Microsoft.EntityFrameworkCore.Relational 3.0.0 与 netcoreapp3.0 (.NETCoreApp,版本=v3.0(。Package Microsoft.EntityFrameworkCore.Relational 3.0.0 支持:netstandard2.1 (.NETStandard,版本=v2.1((

[错误] 包恢复失败

关于如何解决这个问题的任何想法?

1(我设法使用以下方法复制了您的问题:

  • 您的管道
  • 示例项目(源(

2(我注释掉了Nuget任务中的versionSpec,之后管道成功完成:

- task: NuGetToolInstaller@1
displayName: 'Use NuGet 4.9.1'
inputs:
# versionSpec: 4.9.1
checkLatest: true

3( 自动安装的 NuGet 版本是 5.3.0

最新更新