构建 azure 管道中某些库的“nuget 恢复”问题

Kel*_*iro 3 c# azure .net-core-3.1

我正在使用 netcoreapp3.1,一切都可以使用命令 dotnet Restore 和 dotnet build 进行,但在构建管道中,使用的命令是 nuget Restore,这会导致以下错误:

 Package Microsoft.AspNetCore.JsonPatch 3.1.1 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.AspNetCore.JsonPatch 3.1.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
    Package Microsoft.Extensions.Logging.Abstractions 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.Logging.Abstractions 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
    Package Microsoft.Extensions.DependencyInjection.Abstractions 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.DependencyInjection.Abstractions 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
    One or more packages are incompatible with .NETCoreApp,Version=v3.1.
Run Code Online (Sandbox Code Playgroud)

Mat*_*nes 5

在我的场景中,我必须安装 NuGet 5.4.0(与 .NET Core 3.1 一起发布)来解决此问题

如果在 Azure DevOps 中使用 YAML 模板,您可以添加此任务:

- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '5.4.0'
Run Code Online (Sandbox Code Playgroud)