runner-images icon indicating copy to clipboard operation
runner-images copied to clipboard

NET SDK msbuild conflict in 20221127.1

Open rfdrake opened this issue 2 years ago • 2 comments

Description

I tried building a project with dotnet 7.x.x and got an error that said msbuild was too old.

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

I then specified 6.0.403 in global.json and it also required a newer version of MSbuild than what was installed.

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

I'm not that familiar with the dotnet toolchain so I don't know if this is something that can be fixed with more options in our pipeline or other config files, or if it's an actual bug in the runner image.

Platforms affected

  • [X] Azure DevOps
  • [ ] GitHub Actions - Standard Runners
  • [ ] GitHub Actions - Larger Runners

Runner images affected

  • [ ] Ubuntu 18.04
  • [ ] Ubuntu 20.04
  • [X] Ubuntu 22.04
  • [ ] macOS 10.15
  • [ ] macOS 11
  • [ ] macOS 12
  • [ ] Windows Server 2019
  • [ ] Windows Server 2022

Image version and build link

20221127.1

Is it regression?

20221002.2

Expected behavior

It should build with the installed version of msbuild.

Actual behavior

I get an error saying dotnet SDK requires msbuild 17.x.x.

Repro steps

Here is a copy of part of our azure-pipeline.yml with some details removed. We have not yet tried to run this on an older ubuntu image, but that is going to be our next step to work around the problem.

trigger:
  - development
  - stage
  - production

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
  - task: NuGetCommand@2
    inputs:
      command: 'restore'
      restoreSolution: '**/*.sln'
      feedsToUse: 'select'
      vstsFeed: '<a uuid>'
      
  - task: DotNetCoreCLI@2
    inputs:
      command: 'build'
      projects: 'api/projectdirectory'
      arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)/api'      

rfdrake avatar Dec 01 '22 20:12 rfdrake

hello @rfdrake, could you please provide minimal steps so we can try to reproduce the issue?

ddobranic avatar Dec 02 '22 08:12 ddobranic

I'm going to try to make a public repo with a baseline config that reproduces the issue. I'll post here with links to the repo if I can get it to fail the same way.

rfdrake avatar Dec 02 '22 14:12 rfdrake

@rfdrake as ubuntu images have both .NET and mono installed it also has 2 flavours of msbuild installed as the msbuild and dotnet msbuild accordingly. From your yaml snippet and the output it looks like you are using the dot net core task but call msbuild from mono. You can compare its versions by calling msbuild --version and dotnet msbuild --version

mikhailkoliada avatar Dec 02 '22 20:12 mikhailkoliada

It appears to not be caused by ubuntu-runner, but somewhere in our dependencies or some other aspect of our project. Here is what I've been able to figure out so far:

  1. It works when we switch from ubuntu-latest to ubuntu-20.04
  2. I've thrown together the same dependencies in a test repository and can't get it to fail:

https://dev.azure.com/gigaMonster/example%20of%20msbuild%20issue/_git/example%20of%20msbuild%20issue

Here is a longer example of the error message. I'm not sure if the msbuild message is the cause, or the 'Microsoft.NET.Sdk.Worker' message is the cause. I'm guessing the NuGet task must be calling the msbuild from mono based on @mikhailkoliada 's reply, since this all happens in the NuGetCommand phase.

2022-12-02T20:09:40.5749231Z /home/vsts/work/1/s/api/Franklin.WorkerService/Franklin.WorkerService.csproj : error : Version 7.0.100 of the .NET SDK requires at least version 17.3.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.
2022-12-02T20:09:40.5751220Z /home/vsts/work/1/s/api/Franklin.WorkerService/Franklin.WorkerService.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Worker' specified could not be found.
2022-12-02T20:09:40.5752286Z /home/vsts/work/1/s/api/Franklin.MoveOutWorker/Franklin.MoveOutWorker.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Worker' specified could not be found.
2022-12-02T20:09:40.5753776Z /home/vsts/work/1/s/api/Franklin.SalesForce.ResidentWorker/Franklin.SalesForce.ResidentWorker.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Worker' specified could not be found.
2022-12-02T20:09:40.5754758Z /tmp/NuGetScratch/iv02szy6.ij8.nugetrestore.targets(298,5): warning MSB4181: The "MSBuild" task returned false but did not log an error. [/tmp/NuGetScratch/a9gckcw4.1i4.nugetinputs.targets]
2022-12-02T20:09:40.5756187Z /tmp/NuGetScratch/iv02szy6.ij8.nugetrestore.targets(310,5): warning : Skipping restore for project '/home/vsts/work/1/s/api/Franklin.WorkerService/Franklin.WorkerService.csproj'.  The project file may be invalid or missing targets required for restore. [/tmp/NuGetScratch/a9gckcw4.1i4.nugetinputs.targets]
2022-12-02T20:09:40.5757939Z /tmp/NuGetScratch/iv02szy6.ij8.nugetrestore.targets(310,5): warning : Skipping restore for project '/home/vsts/work/1/s/api/Franklin.MoveOutWorker/Franklin.MoveOutWorker.csproj'.  The project file may be invalid or missing targets required for restore. [/tmp/NuGetScratch/a9gckcw4.1i4.nugetinputs.targets]

rfdrake avatar Dec 02 '22 20:12 rfdrake

I'm closing this since I don't believe it's an ubuntu-runner issue. If anyone has any hints about what might fix it please let me know. Our current plan is to stay on ubuntu-20.04.

rfdrake avatar Dec 03 '22 15:12 rfdrake