如何将TFS变量传递给项目的MSBuild任务 [英] How to pass TFS variable to a MSBuild task of the project

查看:48
本文介绍了如何将TFS变量传递给项目的MSBuild任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于TFS服务器的解决方案.该解决方案包括几个具有自定义MSBuild任务的项目.这些任务实际上创建了一些zip存档.

I have a solution which is built on TFS server. This solution includes several projects which have custom MSBuild tasks. Theses tasks actually create some zip archives.

我需要以某种方式从TFS构建中提取$(Rev)宏,并将其传递给任务.我尝试在构建定义的进程"选项卡中使用MSBuildArguments,当我设置一个简单的字符串值(如:

I need to extract somehow the $(Rev) macros from the TFS build and pass it to the tasks. I tried to use MSBuildArguments in the process tab of the build definition and it works when I set a simple string value like:

/p:Version ="5"

/p:Version="5"

但不适用于宏:

/p:Version ="$(Rev:r)"

/p:Version="$(Rev:r)"

你有什么主意吗?

我实际上需要BuildDetail.BuildNumber.

I actually needed BuildDetail.BuildNumber.

推荐答案

您可以稍微更改构建过程模板以实现该目标.
默认情况下,与MSBuild相关的部分如下所示:

可以将其扩展为以下内容:


如果您现在输入构建定义的"MSBuild Arguments"(类似于您的图片),例如/p:Version=RePlAcE,您应该得到所需的内容.

在不需要此内容的另一个构建定义中,只需将条目保留为空.这种方法是在此处的一种替代方法. a>,如果不是所有使用该版本的构建定义都明确需要此版本插入,则应选择该版本.

You can slightly change your build process template to achieve that.
By default the section that relates to MSBuild looks like this:

This could be expanded into something like this:


If you now enter in "MSBuild Arguments" of your build definition (similar to your picture) something like /p:Version=RePlAcE, you should get what you need.

In another build definition where you don't need this, simply leave the entry empty. This approach is an alternative to the one found here, and should be chosen if this version-insertion is not explicitly desired for all build definitions consuming it.

这篇关于如何将TFS变量传递给项目的MSBuild任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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