.NET Core SDK 5.0.100 导致 Nuget 还原失败

Eri*_*ick 4 msbuild nuget azure-devops .net-5

我刚刚更新了一个解决方案来使用net50,它在本地构建,但不在 Azure 管道中构建。如何指定能够构建net50项目的 Azure 管道代理?


管道在nuget restore步骤上失败并出现以下错误:

The nuget command failed with exit code(1) and error([***].csproj : error : 
Version 5.0.100 of the .NET Core SDK requires at least version 16.8.0 of MSBuild. 
The current available version of MSBuild is 16.7.0.37604. 
Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
Run Code Online (Sandbox Code Playgroud)

我的管道 yaml 包括:

The nuget command failed with exit code(1) and error([***].csproj : error : 
Version 5.0.100 of the .NET Core SDK requires at least version 16.8.0 of MSBuild. 
The current available version of MSBuild is 16.7.0.37604. 
Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
Run Code Online (Sandbox Code Playgroud)

Eri*_*ick 5

使用该NuGetCommand@2步骤的解决方法是改用该DotNetCoreCLI@2步骤。如果您正在构建遗留(非 SDK)项目,这可能不可行。

我的 YAML 现在是:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Debug'

steps:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 5.x
    installationPath: $(Agent.ToolsDirectory)/dotnet

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'config'
    nugetConfigPath: 'nuget.config'
Run Code Online (Sandbox Code Playgroud)

感谢@Krzysztof 为我指明了正确的方向。

FWIW,这是从内存中得出的,DotNetCoreCLI@2用于一个net48项目 - 碰巧包含在此管道的解决方案中 - 在 下失败netcoreapp3.1,但似乎在net50.