问题
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.
回答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.
回答2:
After you install new software on a build agent, the agent has to be restarted before new capabilities will be discovered.
来源:https://stackoverflow.com/questions/45567632/visual-studio-2015-express-not-recognised-by-private-build-agent