将日期和修订号设置为 tfs 2017 中的变量 [英] Setting a date and revision number as variables in tfs 2017

查看:18
本文介绍了将日期和修订号设置为 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 .

因为您打算将其用作 Nuget 包版本.您可以直接在 Nuget 包任务.

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屋!

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