在tfs 2017中将日期和修订号设置为变量 [英] Setting a date and revision number as variables in tfs 2017
问题描述
我想创建一个名为NugetVersionNumber的变量,其值的日期格式为$(Date:yyyy.MM.dd)$(Rev:.rr),最后是修订版.
I want to create a variable named NugetVersionNumber with the value a date format of $(Date:yyyy.MM.dd)$(Rev:.rr) with the revision at the end.
例如
2018.8.23.1
2018.8.23.1
如何在不更改build.buildnumber变量的情况下设置过程变量以构造此格式?
How do I set a process variable to construct this format without changing the build.buildnumber variable?
推荐答案
它不能直接将 $(Date:yyyy.MM.dd)$(Rev:.rr)
用作 用户定义的变量.(Date:yyyyMMdd)
是内部版本号格式的令牌不是通用变量.
It's not able to directly use $(Date:yyyy.MM.dd)$(Rev:.rr)
as a user-defined variables. (Date:yyyyMMdd)
is a token of build number format not a general variable.
唯一的方法是使用(Date:yyyy.MM.dd)$(Rev:.rr)
格式设置内部版本号.然后直接使用 $(Build.BuildNumber)
变量.
The only way to do this is setting your build number with (Date:yyyy.MM.dd)$(Rev:.rr)
format. And then directly use the $(Build.BuildNumber)
variable .
Since you are going to use this as a Nuget Package Version. You could directly check the Use the build number to version package in Nuget Package task.
要使用内部版本号,请选中使用内部版本号进行版本打包"框,然后按照代码行的说明进行操作(将鼠标悬停在蓝色的 i 图标上)设置构建版本格式字符串.您必须设置构建版本格式化字符串,使其至少三部分之间用句点分隔避免在NuGet包装中出错.默认的构建版本格式字符串是
$(date:yyyyMMdd)$(rev:.r)
,因此一个简单的更改是添加一个末尾为零,介于日期和生成计数器之间的时间段:$(date:yyyyMMdd).$(rev:.r).0
.
To use the build number, check the Use build number to version package box and follow the line's instructions (hover over the blue i icon) to set the build version format string. You must set the build version format string to have at least three parts separated by periods to avoid an error in NuGet packaging. The default build version format string is
$(date:yyyyMMdd)$(rev:.r)
, so a simple change is to add a zero at the end and a period between the date and build counter:$(date:yyyyMMdd).$(rev:.r).0
.
这篇关于在tfs 2017中将日期和修订号设置为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!