I just updated a solution to use net50
, and it builds locally, but does not build in an Azure pipeline. How do I specify an Azure pipeline agent capable of building net50
projects?
The pipeline fails on the nuget restore
step with the following error:
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:
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. This may not be viable if you are building legacy (non-SDK) projects.
My YAML is now:
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With