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

孤者浪人 提交于 2019-12-03 12:44:18

You have a few options:

  1. '$(BuildingInsideVisualStudio)' != ''
  2. '$(TeamBuildConstants)' != '' (supported in team Build 2008)
  3. '$(IsDesktopBuild)' == 'false'

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.

I have TFS2012 and use this:

<IsTfsServerBuild Condition=" '$(IsTfsServerBuild)' == '' ">false</IsTfsServerBuild>
<IsTfsServerBuild Condition=" '$(BuildingInsideVisualStudio)' != 'true' AND '$(BuildUri)' != '' ">true</IsTfsServerBuild>

When calling MSBuild from the command line, you can pass/overwrite properties like this:

# Simulate Visual Studio build
. msbuild.exe Project.csproj /p:BuildingInsideVisualStudio=true [...]

# Custom property
. msbuild.exe Project.csproj /p:MyCustomProperty=true [...]

Is use these to check them in my post/afterbuild events.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!