Azure build pipeline incompatible msbuild version ubuntu build agent

Bernard, Jacob 0 Reputation points
2025-04-07T15:29:42.83+00:00

Hi, on the "Restore Solution" step of my build azure build pipeline I am getting the following error:

##[error]The nuget command failed with exit code(1) and error(/home/vsts/work/1/s/Web/ElDorado.Web/ElDorado.Web.csproj : error : Version 8.0.407 of the .NET SDK requires at least version 17.8.3 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.

This is running the "ubuntu-latest" vm-image, this doesn't occur with a windows build agent but it seems we must use an ubuntu build agent for the AzureStaticWebApp@0 task.

Here is out build pipeline:

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - 1855-PrototypeBlazor
trigger:
  branches:
    include:
      - 1855-PrototypeBlazor    
    
variables:
  solution: '**/*.sln'
  buildConfiguration: 'Release'

jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-22.04
  variables:
  - group: Azure-Static-Web-Apps-salmon-wave-05885360f-variable-group
  steps:
  - checkout: self
    submodules: true

  - task: NuGetToolInstaller@1
    displayName: "Install Nuget"  

  - task: NuGetAuthenticate@1
    displayName: 'Trackhouse Nuget Authenticate'
    inputs:
      forceReinstallCredentialProvider: true


  - task: NuGetCommand@2
    displayName: "Restore Solution"
    inputs:
      command: 'restore'  
      restoreSolution: '$(solution)'
      feedsToUse: 'select'
      vstsFeed: '*GUID hidden*'
      includeNuGetOrg: false
    

  - task: DotNetCoreCLI@2
    displayName: "Build Solution"
    name: "build"
    inputs:
      command: 'build'
      projects: '$(solution)'
      arguments: '--configuration $(buildConfiguration)'  
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(*Token hidden but was auto-generated*)
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
      app_location: "/Web//ElDorado.Web" # App source code path
      api_location: "Api" # Api source code path - optional
      output_location: "wwwroot" # Built app content directory - optional
###### End of Repository/Build Configurations ######


Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,131 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bernard, Jacob 0 Reputation points
    2025-04-07T20:49:25.0966667+00:00

    Took too long to realize but turns out we should be using a DotnetCoreCLI@2 task NOT a Nuget Command which in hindsight is super obvious. instead of the vsts feed input we are using a nuget.config file in our solution which is accomplishing the same thing. So our pipeline ended up at this, also of major note is that we are seperately building restoring, publishing, and then running the AzureStaticWebApp task without building as it was unable to find out private feed based on this post

      
    name: Azure Static Web Apps CI/CD
    
    pr:
      branches:
        include:
          - 1855-PrototypeBlazor
    trigger:
      branches:
        include:
          - 1855-PrototypeBlazor    
        
    variables:
      solution: '**/*.sln'
      buildConfiguration: 'Release'
    
    jobs:
    - job: build_and_deploy_job
      displayName: Build and Deploy Job
      condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
      pool:
        vmImage: ubuntu-latest
      variables:
      - group: [Resource Group]
      steps:
      - checkout: self
        submodules: true
    
      - task: NuGetToolInstaller@1
        displayName: "Install Nuget"  
    
      - task: NuGetAuthenticate@1
        displayName: 'Nuget Authenticate'
        inputs:
          forceReinstallCredentialProvider: true
        
      - task: DotNetCoreCLI@2
        inputs:
          command: 'restore'
          projects: '$(solution)'
          feedsToUse: 'config'
          nugetConfigPath: './nuget.config'
      
      - task: DotNetCoreCLI@2
        displayName: "Build Solution"
        name: "build"
        inputs:
          command: 'build'
          projects: '$(solution)'
          arguments: '--configuration $(buildConfiguration)'  
    
      - task: DotNetCoreCLI@2
        displayName: 'Publish'
        inputs:
          command: 'publish'
          publishWebProjects: true
          arguments: '--configuration $(buildConfiguration)'  
          zipAfterPublish: false
    
      - task: AzureStaticWebApp@0
        inputs:
          skip_app_build: true
          azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_*)
          app_location: "/Web/ElDorado.Web/bin/Release/net9.0/publish/wwwroot" # App source code path
          output_location: '' # Built app content directory - optional
    
    

  2. Laxman Reddy Revuri 3,985 Reputation points Microsoft External Staff
    2025-04-08T13:32:08.44+00:00

    Hi @Bernard, Jacob
    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer
    Ask: Azure build pipeline incompatible msbuild version ubuntu build agent
    Solution:
    Took too long to realize but turns out we should be using a DotnetCoreCLI@2 task NOT a Nuget Command which in hindsight is super obvious. instead of the vsts feed input we are using a nuget.config file in our solution which is accomplishing the same thing. So our pipeline ended up at this, also of major note is that we are seperately building restoring, publishing, and then running the AzureStaticWebApp task without building as it was unable to find out private feed based on this post

      
    name: Azure Static Web Apps CI/CD
    
    pr:
      branches:
        include:
          - 1855-PrototypeBlazor
    trigger:
      branches:
        include:
          - 1855-PrototypeBlazor    
        
    variables:
      solution: '**/*.sln'
      buildConfiguration: 'Release'
    
    jobs:
    - job: build_and_deploy_job
      displayName: Build and Deploy Job
      condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
      pool:
        vmImage: ubuntu-latest
      variables:
      - group: [Resource Group]
      steps:
      - checkout: self
        submodules: true
    
      - task: NuGetToolInstaller@1
        displayName: "Install Nuget"  
    
      - task: NuGetAuthenticate@1
        displayName: 'Nuget Authenticate'
        inputs:
          forceReinstallCredentialProvider: true
        
      - task: DotNetCoreCLI@2
        inputs:
          command: 'restore'
          projects: '$(solution)'
          feedsToUse: 'config'
          nugetConfigPath: './nuget.config'
      
      - task: DotNetCoreCLI@2
        displayName: "Build Solution"
        name: "build"
        inputs:
          command: 'build'
          projects: '$(solution)'
          arguments: '--configuration $(buildConfiguration)'  
    
      - task: DotNetCoreCLI@2
        displayName: 'Publish'
        inputs:
          command: 'publish'
          publishWebProjects: true
          arguments: '--configuration $(buildConfiguration)'  
          zipAfterPublish: false
    
      - task: AzureStaticWebApp@0
        inputs:
          skip_app_build: true
          azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_*)
          app_location: "/Web/ElDorado.Web/bin/Release/net9.0/publish/wwwroot" # App source code path
          output_location: '' # Built app content directory - optional
    

     Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members. 

    0 comments No comments

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.