TFS 2010 : Use the label name in build number format

夙愿已清 提交于 2019-12-12 12:40:17

问题


I'm trying to setup a build with TFS 2010. I want the build number format to be something like $(BuildDefinitionName)_$(version) where $(Version) is the version (label or changeset) specified in the "Get Version" field in the "Queue Build" dialog. If there's no specific version, I would like the version to be latest.

I googled for that but I'm new to msbuild and TFS build so I'm not sure what I should look for to get started.

Thanks.


回答1:


The Microsoft.TeamFoundation.Build.Workflow.Activities.UpdateBuildNumber activity in your build template (e.g. DefaultTemplate.xaml) is what does the work of transforming your build number format string. It takes any of the parameters listed here, however, the version (your changeset or label) is not one of the supported tags.

One workaround I've found that does not require custom code is to edit the BuildNumberFormat argument immediately before the Update Build Number activity uses it.

  1. Open up the xaml template using the GUI editor and find the Update Build Number activity at the top.
  2. Find the Primitives -> Assign activity in the Toolbox. Drag and drop that just above the Update Build Number.
  3. Edit the Assign activity to assign the value String.Format("$(BuildDefinitionName)_$(Date:yyyyMMdd)_{0}$(Rev:.r)", BuildDetail.SourceGetVersion) to BuildNumberFormat. The SourceGetVersion will pull the changeset number or label used to trigger the build. If nothing is specified in the Get Version dialog when you're queuing your build then the changeset number is used by default (e.g. C16044).



回答2:


this is a good start http://www.ewaldhofman.nl/post/2010/06/01/Customize-Team-Build-2010-e28093-Part-10-Include-Version-Number-in-the-Build-Number.aspx



来源:https://stackoverflow.com/questions/5950456/tfs-2010-use-the-label-name-in-build-number-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!