We use TFS 2010.
There are a couple of projects with deployment steps which must know whether they are running on a dev machine or on the TFS build agent.
Right
I thought to provide my own answer updated to 2020.
The way we do it is by checking an environment variable, because TFS (now Azure DevOps) exposes build variables through the environment. When tested in msbuild code they look the same build variables passed on the msbuild command line, but we also employ powershell scripts, which rely only on the environment.
Also, I would sometimes like to distinguish between the Build and the Release pipeline, because in the classic Release pipeline (as opposed to yaml, which we do not have on prem) some things do not work the same (like vsts logging commands)
So, here is what we are using:
BUILD_BUILDNUMBER
- exists in both build and release, because all of our releases include a build artifactRELEASE_ENVIRONMENTNAME
- exists only in the classic release pipelineTF_BUILD
- not sure if exists in release, definitely in buildI would not bother with BuildingInsideVisualStudio
, because it is false when build with msbuild on the command line, yet it is not a build on the CI server.