1
votes

I have a build which works fine locally (VSCode, .NET Core 3.1.101) but fails with the following message when run in an Azure DevOps Pipeline.

My pipeline is stripped down to the most basic:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

And that results in this error message:

Version 3.1.101 of the .NET Core SDK requires at least version 16.3.0 of MSBuild. The current available version of MSBuild is 15.9.21.664. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.

I can't find a way to change the version of MSBuild that the pipeline runs and changing to an older version of .NET Core surely defeats the purpose of upgrading?

Is there any way to build a.NET Core 3.1 solution on Azure DevOps?

2
can you post how does your task looks likeSajeetharan
Good point. I've added the YAML for the build steps to question.SimonF
The windows-2019 image with 16.4 but you are referring to 15.9. version, so it seems related to your project, would you please share a sample to us to reproduce this issue?Leo Liu-MSFT

2 Answers

1
votes

I do not see anywhere you are having the dotnet build task, you need to have the dotnetbuild task with the version configured,

steps:

    - task: UseDotNet@2 
      displayName: ".NET Core 3.1.x"
      inputs:
        version: '3.1.x'
        packageType: sdk
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'dotnet build $(buildConfiguration)'

Refer this article.

1
votes

You should be able to restore nuget packages, compile nad run unit tests using this YAML


pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'
  rootDirectory: '$(Build.SourcesDirectory)'

steps:

- task: DotNetCoreCLI@2
  displayName: Restore nuget packages
  inputs:
    command: restore
    projects: '**/*.csproj'
    workingDirectory: $(rootDirectory)

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: build
    projects: '$(rootDirectory)/*.sln'
    arguments: '--configuration $(buildConfiguration)'

# You just added coverlet.collector to use 'XPlat Code Coverage'
- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: '*Tests/*.csproj'
    arguments: '--configuration $(buildConfiguration) --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true'
    workingDirectory: $(rootDirectory)

I assumed that you solution file is in the root directory. If you use global json please set sdk version to 3.1.201 otherwise another steo may be required.

global.json

{
  "sdk": {
    "version": "3.1.201",
    "rollForward": "latestFeature"
  }
}