[英]Nuget restore fails with .NET Core SDK 5.0.100
I just updated a solution to use net50
, and it builds locally, but does not build in an Azure pipeline.我刚刚更新了一个使用
net50
的解决方案,它在本地构建,但不在 Azure 管道中构建。 How do I specify an Azure pipeline agent capable of building net50
projects?如何指定能够构建
net50
项目的 Azure 管道代理?
The pipeline fails on the nuget restore
step with the following error:管道在
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.
My pipeline yaml includes:我的管道 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'
A workaround to using the NuGetCommand@2
step is to use the DotNetCoreCLI@2
step instead.使用
NuGetCommand@2
步骤的解决方法是改用DotNetCoreCLI@2
步骤。 This may not be viable if you are building legacy (non-SDK) projects.如果您正在构建遗留(非 SDK)项目,这可能不可行。
My YAML is now:我的 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'
Thanks to @Krzysztof for pointing me in the right direction.感谢@Krzysztof 为我指明了正确的方向。
FWIW, and this is from memory, using
DotNetCoreCLI@2
for anet48
project - which happened to be included in this pipeline's solution - failed undernetcoreapp3.1
, but appears to work undernet50
.FWIW,这是来自 memory,将
DotNetCoreCLI@2
用于net48
项目 - 恰好包含在此管道的解决方案中 - 在netcoreapp3.1
下失败,但似乎在net50
下工作。
It looks that images haven't been updated yet and 16.8 is not available.看起来图像还没有更新,16.8 不可用。 Please check this GitHub issue :
请检查此GitHub 问题:
We keep the visual studio version always up to date.
我们始终保持 visual studio 版本是最新的。 However, deploying images can sometimes take a week(or two).
但是,部署图像有时可能需要一周(或两周)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.