TFS版本+1中的增量变量值 [英] Increment variable value in TFS build +1

查看:64
本文介绍了TFS版本+1中的增量变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有预定义变量$(ProjectBuildNumber)的Microsoft Visual Studio Team Foundation Server(版本15.117.26714.0).

I have a Microsoft Visual Studio Team Foundation Server (Version 15.117.26714.0) with predefined variable $(ProjectBuildNumber).

在构建过程中,是否有任何方法可以将具有较小内部版本号的变量的值增加+1?

Is there any way to increment, during build process, value of variable with minor build number by +1?

$(ProjectBuildNumber)  =   663

因此,在下一个版本中它将是:

So, that on next build it will be:

$(ProjectBuildNumber)  =   664

推荐答案

您不能在构建定义"的内部版本号中引用变量.但是您可以做的是在内部版本号中覆盖内部版本号.您可以使用魔术日志命令,也可以使用我的 VSTS变量任务在构建本身中设置Build.BuildNumber . Variables Task确实会扩展变量引用.您可能只需将值设置为当前值即可对其进行扩展.

You can't reference variables in the build number of the Build Definition. But what you can do is override the build number in the build itself. You can either use a magic log command or use my VSTS Variables Task to set the Build.BuildNumber in the build itself. The Variables Task does expand variable references. You could probably just set the value to the current value to get it expanded.

要自己发出log命令,请使用批处理脚本,PowerShell或bash将以下特定字符串输出到控制台:

To issue the log command yourself use a batch script, PowerShell or bash to output the following specific string to the console:

## vso [build.updatebuildnumber]内部版本号

##vso[build.updatebuildnumber]build number

更新当前版本的内部版本号.示例:

Update build number for current build. Example:

##vso[build.updatebuildnumber]my-new-build-number

最低代理版本:1.88

Minimum agent version: 1.88

源: https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md

另一种选择是使用$(Rev)选项:

An alternative option is to use the $(Rev) option:

Build.BuildNumber = 1.1.$(Rev:.r)  

这将在每次运行构建时自动增加变量.

That will automatically increase the variable each time the build runs.

更新构建定义中的变量,请使用另一个变量扩展名:

这些东西结合起来应该能够得到您想要的东西.

These things combined should be able to get what you want.

这篇关于TFS版本+1中的增量变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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