VSTS IsHostedAgent detection is flawed
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 1h 15m
- Merged PRs (30d)
- 19
Description
When running CakeBuild in VSTS and rely on `Context.TFBuild().IsRunningOnVSTS`. However we have 2 hosted build agents and second build agent is called "Hosted Agent 2". And build is always failing on the second agent.
[Here](https://github.com/cake-build/cake/blob/d8f7fe179bdf41fa9d2dbc426a3bd6fbcef7dcfc/src/Cake.Common/Build/TFBuild/TFBuildProvider.cs#L82) code insists that agent name is exactly "Hosted Agent".
Also We are setting up private build agent and [this code](https://github.com/cake-build/cake/blob/d8f7fe179bdf41fa9d2dbc426a3bd6fbcef7dcfc/src/Cake.Common/Build/TFBuild/TFBuildProvider.cs#L45) does not agree with private build agents. It is still VSTS build, only not run in hosted agent.
I propose to change the check for the agent name to `.StartsWith("Hosted Agent")` and remove check for `IsHostedAgent` from `IsRunningOnVSTS` option.
@agc93 what do you think? (as far as I remember you have done work on this)
I can do PR for this.
Contributor guide
Assessment
This issue has not been assessed yet.