tfs - 在 TFS 构建定义中,可以根据另一个变量定义一个变量吗?

标签 tfs msbuild environment-variables build-process

我有一个工作 MSBuild 文件,其中包含我想要在 TFS 构建中运行的某些目标。这些目标依赖于已定义的某些环境变量和 MSBuild 属性。我的 TFS 构建定义编辑器中有一个“变量”选项卡,表面上我可以在其中设置变量的值,以便在目标运行时确实定义它们,但似乎只允许使用文字值 - 如果我想定义变量就另一个变量(例如%OTHER_VARIABLE%\subfolder)而言,没有发生变量扩展。我尝试了各种指定其他变量的方法(例如 $(OTHER_VARIABLE)),但 MSBuild 始终按字面意思看到该值。

有没有办法根据另一个变量来定义一个变量?

最佳答案

如果您使用的是 TFS 2015,您可以使用此扩展:

https://marketplace.visualstudio.com/items?itemName=jessehouwing.jessehouwing-vsts-variable-tasks

https://github.com/jessehouwing/vsts-variable-tasks/wiki/Expand-Variable

When you define a variable in the Variables screen and use other variables as value, they won't be expanded (as you may have expected). Instead the literal text is passed to the tasks in the workflow. Without this little task the following configuration won't work:

Variable    Value
Build.DropLocation  \\share\drops\$(Build.DefinitionName)\$(Build.BuildNumber)

By adding the Expand variable(s) task to the top of your workflow, it will take care of the expansion, so any task below it will receive the value you're after.

关于tfs - 在 TFS 构建定义中,可以根据另一个变量定义一个变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34007455/

相关文章:

c# - 使用 VSTS/TFS 的 .NET 客户端库检索构建定义的任务列表

visual-studio-2008 - 在Visual Studio中添加引用的HintPath

visual-studio - VsDevCmd和VsMSBuildCmd

msbuild - SonarQube MSBuild 集成失败 : SonarQube was unable to collect the required information about your projects

java - 如何在没有 'illegal reflective access' 的情况下在 Java 中设置环境变量?如何使用附加打开?

node.js - Azure NODE_PATH环境变量没有任何作用

visual-studio-2010 - TFS:在源代码管理中按名称搜索文件

tfs - 让 pickles 导入测试结果的 MSBuild 参数导致非法路径错误

batch-file - VS2015/MsBuild/vsvars32.bat : Cannot determine the location of the VS installation

PERLLIB 成功注入(inject)@INC 数组,但不适用于非交互式 shell