0

If I install Visual Studio 2017 Community edition on a machine and registered it as a build agent, then the 'capabilities' tab against the agent registration shows the following environment variables:

VisualStudio            C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
VisualStudio_15.0       C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
VisualStudio_IDE        C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\
VisualStudio_IDE_15.0   C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\

However, if I install Visual Studio 2015 Express and register it as a build agent, I do not get the equivalent variables. Why is this?

Update

@starain-MSFT eluded to the problem; VS2015 Express does not install all the required registry keys for the agent config script to pick up the installation. Registering the environment variables above manually fools the agent pool into recognising the capabilities msbuild, visualstudio, so now I can trigger builds on that agent happily.

However, it doesn't fool the Visual Studio Build task. I get the following log warning on execution;

##[warning]Visual Studio was not found. Try installing a supported version of Visual Studio. See the task definition for a list of supported versions.

It then reverts back to MSBuild to execute the workflow. Fortunately in my case it completes successfully because I am building a .sln. I just want to warn others out there they may experience similar problems.

Steztric
  • 2,832
  • 2
  • 24
  • 43

2 Answers2

1

There are some PowerShell files in [agent folder]\bin\powershell folder that used to add capabilities, you can check the source code of them.

Based on the code in Add-VisualStudioCapabilities.ps1, it checks HKEY_LOCAL_MACHINE\SOFTWARE\[WOW6432Node]\Microsoft\VisualStudio\[14.0]\ShellFolder and InstallDir. So you can check the keys and values in registry.

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • That's it! For some reason VS2015 Express does not install the `ShellFolder` or `InstallDir` keys! I was worried that the agent script recognised it but refused to register it because we are not allowed to use it for automated builds. I feel more comfortable with it now. – Steztric Aug 09 '17 at 09:36
  • It turns out that is not the full story. When I add the "Visual Studio Build" task to the process, it now executes, but if I look more closely at the log, I can see the following message: "##[warning]Visual Studio was not found. Try installing a supported version of Visual Studio. See the task definition for a list of supported versions." And then it falls back to building with MSBuild. It works because I am building a `.sln`; let's just hope I don't have to build a `.proj`. – Steztric Aug 09 '17 at 13:49
  • What are the right keys and values for VS 2017? I can not see any shellFolder or InstallDir folder in registry? – hasanaydogar Oct 21 '17 at 09:07
-2

After you install new software on a build agent, the agent has to be restarted before new capabilities will be discovered.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • I didn't make myself clear. Machine 1: Install VS2017 Community, register as build agent, the capabilities tab shows as build capable. Machine 2: Install VS2015 Express, register as build agent, the capabilities tab DOES NOT show as build capable. They are different machines, both registered as build agents after installing Visual Studio. – Steztric Aug 08 '17 at 14:37
  • Try VS 2015 Community instead of Express. Express probably doesn't install all of the necessary components. – Daniel Mann Aug 08 '17 at 15:18
  • I'm afraid not. Licensing conditions forbid organisations with more than 300 employees to install Community edition. My question is specifically about VS 2015 Express. Express does install the necessary components because I can hack the system by setting these variables as system environment variables and the build works. I am asking why the agent does not recognise VS 2015 Express as a legitimate VS install. Is it by design or a bug in the agent config script? – Steztric Aug 08 '17 at 15:22