microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.43k stars 2.59k forks source link

[BUG]: Latest version of SDK not found when using demands in pool statement #19004

Closed sayago69 closed 1 month ago

sayago69 commented 9 months ago

Task name

VSBuildV1

Task version

1.214.0

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Microsoft Windows Server 2019 and Azure Pipelines

Task log

2023-09-21T00:26:43.9563374Z ##[section]Starting: Build solution **\*.sln
2023-09-21T00:26:43.9679606Z ==============================================================================
2023-09-21T00:26:43.9679735Z Task         : Visual Studio build
2023-09-21T00:26:43.9679792Z Description  : Build with MSBuild and set the Visual Studio version property
2023-09-21T00:26:43.9679895Z Version      : 1.214.0
2023-09-21T00:26:43.9679944Z Author       : Microsoft Corporation
2023-09-21T00:26:43.9680003Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
2023-09-21T00:26:43.9680095Z ==============================================================================
2023-09-21T00:26:59.5382837Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\vswhere.exe" -version [17.0,18.0) -latest -format json
2023-09-21T00:26:59.7347355Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\vswhere.exe" -version [17.0,18.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
2023-09-21T00:26:59.7900913Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\vswhere.exe" -version [16.0,17.0) -latest -format json
2023-09-21T00:26:59.8919188Z ##[warning]Visual Studio version '17.0' not found. Falling back to version '16.0'.
2023-09-21T00:27:00.2656509Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "D:\a\1\s\MyProject.sln" /nologo /nr:false /t:"Clean" /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=822e82d9-abd0-4587-a71f-ef9c5e59b8b6|SolutionDir=D:\a\1\s|enableOrphanedProjectsLogs=true"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.214.0\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /t:ReleaseBuild /p:DeployOnBuild=false /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:configuration="release" /p:VisualStudioVersion="16.0" /p:_MSDeployUserAgent="VSTS_09832949-f5b1-4f83-9804-28cfd60079c2_build_214_0"
2023-09-21T00:27:00.4209011Z Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
2023-09-21T00:27:00.4924714Z Build started 9/21/2023 12:27:00 AM.
2023-09-21T00:27:01.0343818Z Project "D:\a\1\s\MyProject.sln" on node 1 (Clean;ReleaseBuild target(s)).
2023-09-21T00:27:01.0351820Z ValidateSolutionConfiguration:
2023-09-21T00:27:01.0352259Z   Building solution configuration "release|Mixed Platforms".
2023-09-21T00:27:01.3659212Z ##[error]src\MyProject.Web\MyProject.Web.csproj(0,0): Error : Version 6.0.414 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.
2023-09-21T00:27:01.3667034Z D:\a\1\s\src\MyProject.Web\MyProject.Web.csproj : error : Version 6.0.414 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.
2023-09-21T00:27:01.3869689Z ##[error]src\MyProject.Web\MyProject.Web.csproj(0,0): Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.

Relevant log output

2023-09-21T00:27:01.3659212Z ##[error]src\MyProject.Web\MyProject.Web.csproj(0,0): Error : Version 6.0.414 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.
2023-09-21T00:27:01.3667034Z D:\a\1\s\src\MyProject.Web\MyProject.Web.csproj : error : Version 6.0.414 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.

Aditional info

Hello,

We have recently migrated an old project from .NET Core 2.2 to .NET 6 and, therefore, we had to update our Azure DevOps pipeline to deal with that change. Our pipeline is quite normal: it just gets .NET, gets NuGet, restores NuGet packages, builds, and publishes the artifacts.

Initially, we only changed the UseDotNet@2 task to get version 6.x instead of 2.2.x. Since we were getting the issue described, we also realised that we had to change the vsVersion from 16 to 17 in the build task.

We were still getting the error above until we tried to remove all the demands we had from our pool step. We moved from this:

pool:
  vmImage: 'windows-latest'
  demands:
  - DotNetFramework
  - msbuild
  - visualstudio

To this:

pool:
  vmImage: 'windows-latest'

And, somehow, MSBuild was then able to pick up the appropriate version of the SDK.

We assume there must be a bug in there because we haven't been able to find any documentation about this weird behaviour. If not, it would be nice if anyone could provide an explanation about why this is happening.

Happy to provide further information if needed.

Thanks in advance!

PS: apologies if this is not the correct repo to report this bug but it's the most accurate one I could find.
aleksandrlevochkin commented 9 months ago

Hi @sayago69 thank you for bringing up this issue! We are currently working on higher-priority issues, but we will get back to this one as soon as we can.

sayago69 commented 9 months ago

OK, thanks.

There's no rush as the workaround is easy, but it would be nice to fix it at some point.

kohithreddy commented 9 months ago

Hi @sayago69,

Even the public documentation doesn't show adding demands for a Microsoft-hosted agent pool.

As Microsoft has posted the list of software installed on individual pools, you can review and choose the right pool for execution.

I don't think Microsoft should treat this as a bug or feature to enhance.

sayago69 commented 9 months ago

Well, if the public documentation does not show the demands for a Microsoft-hosted agent pool, then it shouldn't affect the pipeline. That might be acceptable.

But the fact is that when you add the demands then it affects the pipeline with unexpected behaviour since, somehow, it's making MSBuild use the wrong version.

So, from my point of view, either that behaviour is advised or fixed.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days