Home > OS >  Why does vswhere not find VS Build Tools when a specific version is specified?
Why does vswhere not find VS Build Tools when a specific version is specified?

Time:05-13

In our build task log I see,

"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
##[warning]Visual Studio was not found. Try installing a supported version of Visual Studio. See the task definition for a list of supported versions.
##[warning]Unable to find MSBuild version '14.0' for architecture 'x86'. Falling back to version '4.0'.

This is the output I see if I run this command:

"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json    
[]

This is the output I see if I remove the version parameter:

"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
[
  {
    "instanceId": "07f7c44a",
    "installDate": "2022-05-07T03:42:53Z",
    "installationName": "VisualStudio/17.1.6 32421.90",
    "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools",
    "installationVersion": "17.1.32421.90",
    "displayName": "Visual Studio Build Tools 2022",
    "description": "The Visual Studio Build Tools allows you to build native and managed MSBuild-based applications without requiring the Visual Studio IDE. There are options to install the Visual C   compilers and libraries, MFC, ATL, and C  /CLI support.",
    "updateDate": "2022-05-07T03:42:53.2726915Z",
    "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
    "channelId": "VisualStudio.17.Release",
    "channelUri": "https://aka.ms/vs/17/release/channel",
    "installedChannelUri": "https://aka.ms/vs/17/release/channel",
    "releaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.1#17.1.6",
    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288"
  }
]

This is the output I get if I just run:

"D:\DevopsBuildAgents\Agent 1\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe"
Visual Studio Locator version 1.0.62 [query version 3.1.2200.53929]
Copyright (C) Microsoft Corporation. All rights reserved.

I've tried doing a repair install of Visual Studio 2022 Build Tools.

It would appear version 17.x of Build Tools is present. Why is it returning nothing when the version parameter is added to this command, as seen in the agent log?

CodePudding user response:

It turns out that the latest version of Azure Devops 2020.1.1 still does not support Visual Studio 2022. So, even though newer devops agents recognize the software, the Devops Server doesn't query for it properly.

If it were working properly it would issue a version parameter that looks like -version [17.0,18.0) or similar.

Uninstalling Visual Studio 2022 build tools and replacing it with Visual Studio 2019 build tools, solved the problem.

Alternatively, there are at least two solutions I found for replacing the built in tasks in Azure Devops 2020 and enabling support for Visual Studio 2022.

https://github.com/jessehouwing/azure-pipelines-tasks-zips/releases/tag/m204

https://www.almhussar.com/2021/12/25/how-to-build-and-support-net-6-and-vs-2022-projects-using-azure-devops-server-2020/

  • Related