MSBuild fail in my Azure Pipiline

Laurent Guigon 311 Reputation points
2024-02-15T10:24:32.52+00:00

Hello. Sorry for my misuse of the "Azure" tag, but there's no tag for Azure "pipelines". I've encountered an issue with this 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).

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
42,669 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.