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
You have a few options:
'$(BuildingInsideVisualStudio)' != ''
'$(TeamBuildConstants)' != ''
(supported in team Build 2008)'$(IsDesktopBuild)' == 'false'
'$(tf_build)' != ''
(supported in recent versions of Azure Pipelines)You can check either one to detect the context the task has been executed in. If both don't evaluate then MsBuild has been called from the commandline or some other process.