Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one determine if a csproj is being run on a TFS build agent?

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 now they check whether the build is from within Visual Studio assuming that only devs compile from VS. Alas, it means I cannot compile from the command line!

So, my question is how an msbuild script can determine if it is being run by the TFS build agent?

like image 836
mark Avatar asked Dec 05 '13 13:12

mark


1 Answers

You have a few options:

  1. '$(BuildingInsideVisualStudio)' != ''
  2. '$(TeamBuildConstants)' != '' (supported in team Build 2008)
  3. '$(IsDesktopBuild)' == 'false'
  4. '$(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.

like image 140
jessehouwing Avatar answered Sep 19 '22 13:09

jessehouwing