使用.NET Core SDK 5.0.100时,Nuget还原失败



我刚刚更新了一个使用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.

我的管道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: NuGetCommand@2
displayName: 'nuget restore'
inputs:
restoreSolution: '**/*.sln'
feedsToUse: config
nugetConfigPath: 'NuGet.config'

使用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'

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

FWIW,这是来自内存的,对net48项目使用DotNetCoreCLI@2(恰好包含在该管道的解决方案中(在netcoreapp3.1下失败,但在net50下似乎可以工作。

看起来图像还没有更新,16.8也不可用。请查看此GitHub问题:

我们始终保持visual studio版本的最新版本。但是,部署映像有时可能需要一周(或两周(的时间。

最新更新