powershell - PowerShell 脚本中的 TFS 2012 构建变更集版本
问题描述
我们有一个 TFS 2012 实例和一个带有 VS 2017 的构建代理。我正在尝试修改 XAML 构建模板以从给定项目创建一个 nuget 包。我需要将变更集编号放在包的描述中,但我无法获得正确的值。
我的模板的 AgentScope 中有一个 InvokeProcess 活动,它运行 PowerShell 脚本来打包包。我尝试获取 TF_BUILD_* 环境变量,但似乎没有填充。我也尝试了 BUILD_SOURCEVERSION ,但没有运气。目前我正在传递 BuildDetail.SourceGetVersion 值,但这是返回整个团队项目的当前变更集,而不是我正在构建的特定项目。
我究竟做错了什么?这些变量是否仅在 TFS 服务器上而不在代理(构建服务器)上?
解决方案
TFS 2012 build changeset version in PowerShell script
According to the article Build Script Hooks for TFS 2012 Builds:
When I created a script for a 2013 build to version the assemblies, I relied on the fact that the 2013 build sets some environment variables that you can use in your scripts.You can see I’m getting $env:TF_BUILD_BUILDNUMBER. Well, in the 2012 workflow, these variables aren’t set, so you have to add an activity to do it.
That the reason why you tried getting the TF_BUILD_* environment variables but none seem to be populated.
So, to resolve this issue, you can just to follow the steps in Challenge 2 to set it.
Or, you can use TFS API to get the latest changeset number in your TFS version control:
Please see this thread for detailed information:
Programmatically retrieve the latest changeset number available in a workspace
Then you can write another small program to modify your description field in the .cs
file be the changeset number you get in above.
Hope this helps.
推荐阅读
- amazon-web-services - 谁能给我一个自定义 CloudWatch 事件模式的示例
- elm - 悬停在榆树(elm-ui)中时如何使文本删除线?
- python - 我如何知道 librosa 进行傅里叶变换的数据中的目标 Hz
- flutter - Flutter:列表已弃用?
- python - 如何匹配 Lark 中的开始和结束标签?
- python - 如何从 pytesseract 获得最佳结果?
- flutter - Flutter (\t) 字符串值对齐问题
- r - 这个 R 函数导出每个形状的面积有什么问题?
- arrays - 数组 - C 中的 DS HackerRank
- ios - 在 TextField 中的空格后自动触发 shift 按钮 - SwiftUI