I’ve encountered an issue with this Azure pipeline:
trigger:
- integration
pool:
vmImage: 'Ubuntu-22.04'
variables:
buildConfiguration: 'Release'
stages:
- stage: ContinousIntegration
jobs:
- job: BuildTestAndPublish
displayName: 'Build, Test and Publish the app'
steps:
- checkout: self
# Tâche pour mettre à jour MSBuild
- script: |
sudo apt update
sudo apt install -y wget apt-transport-https
wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install -y msbuild
displayName: 'Install MSBuild'
# Tâche pour installer le SDK BlazorWebAssembly
#- script: |
# dotnet tool install -g Microsoft.AspNetCore.Blazor.WebAssembly.Tool --version 8.0.2
# displayName: 'Install Blazor WebAssembly SDK'
#- task: NuGetToolInstaller@1
# displayName: 'Update NuGet'
# inputs:
# versionSpec: ''
# checkLatest: false
- task: NuGetCommand@2
displayName: 'dotnet restore'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: DotNetCoreCLI@2
displayName: 'unit testing'
inputs:
command: 'test'
projects: '**/*.UnitTest.csproj'
arguments: '--configuration $(buildConfiguration)'
testRunTitle: 'Unit Tests'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(buildConfiguration) --output $(build.ArtifactStagingDirectory)'
zipAfterPublish: true
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
Here’s a snippet of the error message:
##[error]The nuget command failed with exit code(1) and error(/home/vsts/work/1/s/WebApp/Alurnet.Oniria.Encyclopedia.v7.WebApp.Client/Alurnet.Oniria.Encyclopedia.v7.WebApp.Client.csproj : error : Version 8.0.101 of the .NET SDK requires at least version 17.7.0 of MSBuild. The current available version of MSBuild is 16.10.1.31701. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.
The NuGet Restore task is the one that failed.
I don’t understand this problem because I know that version 17.9.5.7608 exists, as it’s the one installed on my development computer (in VS2022-c). However, this version is not available for the Ubuntu 22.04 VM, which I chose for my Azure App Service (it’s cheaper than using Windows servers).
My app is a [new pattern] Blazor Web App .Net core 8.0.200
This code is the last version I tried…
2
Answers
Thank-you! I've tried to changed the NuGetCommand command by the DotNetCoreCLI command and it works!
My Code is now like this :
And It's good...
Since you build your solution using
dotnet
CLI based tasks, you should be fine by using the SDK alone and you can remove the step downloading and installing the standalone mono-based MSBuild.If you have build customizations that require an
msbuild
executable to exist, you can rewrite them to usedotnet msbuild
as a drop-in replacement instead to use the .NET (5+/Core) based version of MSBuild that ships as part of the .NET SDK.I also suggest replacing the nuget restore task with another DotNetCoreCLI task that performs the restore command. But you can also remove that if you have incompatible projects in the solution since the
build
command now performs an implicit restore (when necessary) automatically for the csproj file and graph that you are building.