如何确定csproj是否在TFS构建代理上运行? [英] How can one determine if a csproj is being run on a TFS build agent?

查看:65
本文介绍了如何确定csproj是否在TFS构建代理上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用TFS 2010.

We use TFS 2010.

有几个带有部署步骤的项目,必须知道它们是在开发机器上运行还是在TFS构建代理上运行.

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.

现在,他们假设仅开发人员是从VS编译的,因此他们检查构建是否来自Visual Studio. las,这意味着我无法从命令行进行编译!

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!

所以,我的问题是msbuild脚本如何确定TFS生成代理是否正在运行它?

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

推荐答案

您有一些选择:

  1. '$(BuildingInsideVisualStudio)' != ''
  2. '$(TeamBuildConstants)' != ''(在Build 2008组中受支持)
  3. '$(IsDesktopBuild)' == 'false'
  4. '$(tf_build)' != ''(在最新版本的Azure Pipelines中受支持)
  1. '$(BuildingInsideVisualStudio)' != ''
  2. '$(TeamBuildConstants)' != '' (supported in team Build 2008)
  3. '$(IsDesktopBuild)' == 'false'
  4. '$(tf_build)' != '' (supported in recent versions of Azure Pipelines)

您可以选择其中一个来检测任务在其中执行的上下文.如果两者都不进行评估,则说明已从命令行或其他进程调用了MsBuild.

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.

这篇关于如何确定csproj是否在TFS构建代理上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆