Skip to main content

Azure DevOps Pipelines–How the build agent detects Visual Studio related capabilities

Detecting if Visual Studio is installed on the build server can be quite painful. I’ve seen a few times where the build agent didn’t pick up the Visual Studio installation, making the build server useless. As Visual Studio is not added to the capabilities of the build agent, the specific agent is never used to conduct a build.

If everything is OK, you should see something like this in your Build Agent capabilities:

But how does the build agent detects that Visual Studio is there?

This is all done through vswhere.exe, a tool I blogged about before. Vswhere is installed as one of the tools of the build agent, but in case of trouble you can run it yourself to see what is going wrong.

Let’s try this:

  • Login on your build server and open the installation folder of one of your build agents.
  • Go to the externals\vswhere  subfolder. Here you should find the vswhere.exe
  • Let’s see what options are available by calling vswhere.exe –help:

PS D:\builds\dev-agent-1\externals\vswhere> .\vswhere.exe -help

Visual Studio Locator version 2.6.13+a6d40ba5f4 [query version 2.1.1046.44959]

Copyright (C) Microsoft Corporation. All rights reserved.

Usage: vswhere.exe [options]

Options:

-all           Finds all instances even if they are incomplete and may not launch.

  -prerelease    Also searches prereleases. By default, only releases are searched.

  -products arg  One or more product IDs to find. Defaults to Community, Professional, and Enterprise.

                 Specify "*" by itself to search all product instances installed.

                 See https://aka.ms/vs/workloads for a list of product IDs.

  -requires arg  One or more workload or component IDs required when finding instances.

                 All specified IDs must be installed unless -requiresAny is specified.

                 See https://aka.ms/vs/workloads for a list of workload and component IDs.

  -requiresAny   Find instances with any one or more workload or components IDs passed to -requires.

  -version arg   A version range for instances to find. Example: [15.0,16.0) will find versions 15.*.

  -latest        Return only the newest version and last installed.

  -sort          Sorts the instances from newest version and last installed to oldest.

                 When used with "find", first instances are sorted then files are sorted lexigraphically.

  -legacy        Also searches Visual Studio 2015 and older products. Information is limited.

                 This option cannot be used with either -products or -requires.

  -format arg    Return information about instances found in a format described below.

  -property arg  The name of a property to return. Defaults to "value" format.

                 Use delimiters ".", "/", or "_" to separate object and property names.

                 Example: "properties.nickname" will return the "nickname" property under "properties".

  -find arg      Returns matching file paths under the installation path. Defaults to "value" format.

                 The following patterns are supported:

                 ?  Matches any one character except "\".

                 *  Matches zero or more characters except "\".

                 ** Searches the current directory and subdirectories for the remaining search pattern.

  -nologo        Do not show logo information. Some formats noted below will not show a logo anyway.

  -utf8          Use UTF-8 encoding (recommended for JSON).

  -?, -h, -help  Display this help message.

Formats:

  json           An array of JSON objects for each instance (no logo).

  text           Colon-delimited properties in separate blocks for each instance (default).

  value          A single property specified by the -property parameter (no logo).

  xml            An XML data set containing instances (no logo).

  • Ok now that we know the available options, let’s have a look at the installed versions using vswhere.exe -all:

PS D:\builds\dev-agent-1\externals\vswhere> .\vswhere.exe -all

Visual Studio Locator version 1.0.62 [query version 2.1.1046.44959]

Copyright (C) Microsoft Corporation. All rights reserved.

instanceId: 1e1d4042

installDate: 14/06/2019

installationName: VisualStudio/16.1.2+29001.49

installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise

installationVersion: 16.1.29001.49

displayName: Visual Studio Enterprise 2019

description: Microsoft DevOps solution for productivity and coordination across teams of any size

updateDate: 2019-06-14T06:17:25.7201719Z

enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualS

tudio.Setup.Service

layoutPath: x:\vs2019

channelId: VisualStudio.16.Release

channelUri: https://aka.ms/vs/16/release/channel

installChannelUri: x:\vs2019\ChannelManifest.json

releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660893#16.1.2

thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909

  • That’s good news, it seems that a version of Visual Studio is installed. Unfortunately the build agent didn’t pick it up. So what is going wrong?
  • Let’s try to use the exact query that the build agent itself is using: vswhere.exe -version '[16.0,17.0)' -latest -format json

PS D:\builds\dev-agent-1\externals\vswhere> .\vswhere.exe -version '[16.0,17.0)' -latest -format json

[]

  • This returns an empty array. Strange! Let’s download and install the latest vswhere version from GitHub. This version has some extra features and can give us more details.
  • After downloading the latest vswhere.exe, let’s run vswhere.exe –all again:

PS D:\soft> .\vswhere.exe -all

Visual Studio Locator version 2.6.13+a6d40ba5f4 [query version 2.1.1046.44959]

Copyright (C) Microsoft Corporation. All rights reserved.

instanceId: 1e1d4042

installDate: 14/06/2019 8:17:25

installationName: VisualStudio/16.1.2+29001.49

installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise

installationVersion: 16.1.29001.49

productId: Microsoft.VisualStudio.Product.Enterprise

productPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe

state: 13

isComplete: 0

isLaunchable: 0

isPrerelease: 0

isRebootRequired: 0

displayName: Visual Studio Enterprise 2019

description: Microsoft DevOps solution for productivity and coordination across teams of any size

channelId: VisualStudio.16.Release

channelUri: https://aka.ms/vs/16/release/channel

enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service

installChannelUri: x:\vs2019\ChannelManifest.json

layoutPath: x:\vs2019

releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660893#16.1.2

thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909

updateDate: 2019-06-14T06:17:25.7201719Z

catalog_buildBranch: d16.1

catalog_buildVersion: 16.1.29001.49

catalog_id: VisualStudio/16.1.2+29001.49

catalog_localBuild: build-lab

catalog_manifestName: VisualStudio

catalog_manifestType: installer

catalog_productDisplayVersion: 16.1.2

catalog_productLine: Dev16

catalog_productLineVersion: 2019

catalog_productMilestone: RTW

catalog_productMilestoneIsPreRelease: False

catalog_productName: Visual Studio

catalog_productPatchVersion: 2

catalog_productPreReleaseMilestoneSuffix: 1.0

catalog_productSemanticVersion: 16.1.2+29001.49

catalog_requiredEngineVersion: 2.1.3095.63072

properties_campaignId: 1079615330.1554282809

properties_canceled: 1

properties_channelManifestId: VisualStudio.16.Release/16.1.2+29001.49

properties_nickname:

properties_operationMode: 0

properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe

  • We get a lot more detail when using the latest version. One thing you should notice is the isComplete value which is 0. Something is definitely wrong with our installation.
  • Let’s compare the output with a server where everything is running fine:

D:\Builds\releases-agent-1\externals\vswhere>vswhere -all

Visual Studio Locator version 1.0.62 [query version 2.1.1046.44959]

Copyright (C) Microsoft Corporation. All rights reserved.

instanceId: 7a2855e5

installDate: 16/04/2019

installationName: VisualStudio/16.1.2+29001.49

installationPath: d:\program files\Visual Studio

installationVersion: 16.1.29001.49

displayName: Visual Studio Enterprise 2019

description: Microsoft DevOps solution for productivity and coordination across teams of any size

updateDate: 2019-06-17T13:57:50.6461374Z

enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service

layoutPath: X:\VS2019

channelId: VisualStudio.16.Release

channelUri: https://aka.ms/vs/16/release/channel

installChannelUri: D:\Soft\vs2019\ChannelManifest.json

releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660893#16.1.2

thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909

Use latest vswhere version returns the following on server where everything is ok:

D:\Soft>vswhere -all

Visual Studio Locator version 2.6.13+a6d40ba5f4 [query version 2.1.1046.44959]

Copyright (C) Microsoft Corporation. All rights reserved.

instanceId: 7a2855e5

installDate: 16/04/2019 16:02:38

installationName: VisualStudio/16.1.2+29001.49

installationPath: d:\program files\Visual Studio

installationVersion: 16.1.29001.49

productId: Microsoft.VisualStudio.Product.Enterprise

productPath: d:\program files\Visual Studio\Common7\IDE\devenv.exe

state: 4294967295

isComplete: 1

isLaunchable: 1

isPrerelease: 0

isRebootRequired: 0

displayName: Visual Studio Enterprise 2019

description: Microsoft DevOps solution for productivity and coordination across teams of any size

channelId: VisualStudio.16.Release

channelUri: https://aka.ms/vs/16/release/channel

enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service

installChannelUri: D:\Soft\vs2019\ChannelManifest.json

layoutPath: X:\VS2019

releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660893#16.1.2

thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909

updateDate: 2019-06-17T13:57:50.6461374Z

catalog_buildBranch: d16.1

catalog_buildVersion: 16.1.29001.49

catalog_id: VisualStudio/16.1.2+29001.49

catalog_localBuild: build-lab

catalog_manifestName: VisualStudio

catalog_manifestType: installer

catalog_productDisplayVersion: 16.1.2

catalog_productLine: Dev16

catalog_productLineVersion: 2019

catalog_productMilestone: RTW

catalog_productMilestoneIsPreRelease: False

catalog_productName: Visual Studio

catalog_productPatchVersion: 2

catalog_productPreReleaseMilestoneSuffix: 1.0

catalog_productSemanticVersion: 16.1.2+29001.49

catalog_requiredEngineVersion: 2.1.3095.63072

properties_campaignId: 1079615330.1554282809

properties_channelManifestId: VisualStudio.16.Release/16.1.2+29001.49

properties_nickname:

properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe

  • This confirms our assumptions. It seems that the Visual Studio installation did not complete.

I opened up the Visual Studio installer and the Visual Studio installation continued. Problem solved!

Popular posts from this blog

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B

Help! I accidently enabled HSTS–on localhost

I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website that was running in IIS and had a certificate configured. But when I tried to run an Angular app a little bit later on http://localhost:4200 the browser redirected me immediately to https://localhost . Whoops! That was not what I wanted in this case. To fix it, you need to go the network settings of your browser, there are available at: chrome://net-internals/#hsts edge://net-internals/#hsts brave://net-internals/#hsts Enter ‘localhost’ in the domain textbox under the Delete domain security policies section and hit Delete . That should do the trick…

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.