tfspreview 上的 tf.exe [英] tf.exe on tfspreview

查看:20
本文介绍了tfspreview 上的 tf.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 tfspreview 中获取 ChangeSetId 以进行持续集成.我只需要这个单一号码而已.我尝试了我能找到的所有可能的 MSBuild 任务,但总是有另一个小问题阻止了我.

I need to get the ChangeSetId in tfspreview for our continuous integration. I just need this single number nothing else. I tried all possible MSBuild tasks that I could find, but there is always another smaller issue stopping me.

对于 MSBuild.ExtensionPack.Tfs.TeamBuild 我得到:

Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

和社区包中的 TfsClient -task(正在生成以下 exec: tf.exe history ./StopAfter:1/noprompt/format:detailed/recursive) 我得到:

and for TfsClient -task in community-pack (which is generating following exec: tf.exe history . /StopAfter:1 /noprompt /format:detailed /recursive) I get:

The specified task executable could not be run. The system cannot find the file specified

我的问题是;是否可以在 tfspreview 服务器上执行 TF.exe?或者我可以在构建服务器上获取程序集 Microsoft.TeamFoundation.Client 来执行这两个任务之一吗?

My question is; Is it possible to execute TF.exe on tfspreview server? or can I get the assembly Microsoft.TeamFoundation.Client on the build server to execute one of these two tasks?

推荐答案

好吧,我在这里告诉你,不用编写你自己的自定义任务,使用 API 等,这是可能的......有很多文章在 StackOverflow 上,但有解决方案的那些似乎不适用于 TFS 2010.我只是花了一整天的时间把头撞在墙上:D

Alright, I am here to tell you that this IS possible without writing your own custom task, using the API, etc... there are a number of articles out here on StackOverflow but the ones with solutions do not appear to work for TFS 2010. I just spent an entire day banging my head against the wall :D

  1. 您需要安装 MSBuild 社区任务.确保您从此处获取最新版本:https://github.com/loresoft/msbuildtasks.最新版本似乎已针对 TFS 2010 程序集进行了更新和重建.

  1. You need to install the MSBuild Community Tasks. Make sure you get the latest version from here: https://github.com/loresoft/msbuildtasks. The latest appears to have been updated and rebuilt against the TFS 2010 assemblies.

您将使用 MSBuild.Community.Tasks.Tfs.TfsClient 任务.您收到无法运行可执行文件的错误的原因是因为这是一个 MSBuild ToolTask​​,您需要将可执行文件的路径作为属性 (ToolPath) 传递给任务.

You are going to use the MSBuild.Community.Tasks.Tfs.TfsClient task. The reason you are getting that error about not being able to run the executable is because this is an MSBuild ToolTask and you need to pass in the path to the executable as a property (ToolPath) to the task.

TfsClient 任务只是 tf.exe 的包装器,该任务缺少许多可能的功能,用于以 MSbuild-y 方式处理开关.(此任务的文档不存在 - 我不得不查看代码)幸运的是,我发现您可以输入所有命令行开关作为命令本身的一部分.

The TfsClient task is just a wrapper to tf.exe and the task is missing a lot of possible features for handling the switches in an MSbuild-y way. (and the documentation for this task is nonexistant - i had to look at the code) Luckily I figured out that you can enter all of the command line switches as part of the command itself.

所以你的最终调用看起来像这样......

So your final call will look something like this...

<MSBuild.Community.Tasks.Tfs.TfsClient ToolPath="$(PathToTfTool)"
                                   Command="history /collection:$(TfsProjectCollectionUrl) /stopafter:1 /version:T /format:detailed $(VersionControlPathForBuildWorkspace)"
                                   Recursive="true"
                                   >

<Message Text="TFS ChangeSetNumber: $(ChangesetNumber)" />

在 22 次失败的构建或没有数据的构建之后,我终于得到了......TFS 变更集编号:41

And after 22 miserable failed builds or builds with no data I finally got... TFS ChangeSetNumber: 41

雅虎!

从马丁伍德沃德那里得到命令:http://www.woodwardweb.com/vsts/determining_the.html确保您使用/detailed 开关,否则它不会返回更改集.我必须查看该任务的代码,并弄清楚它是如何解析 tf.exe 的输出来解决这个问题的.

Got the command from Martin Woodward: http://www.woodwardweb.com/vsts/determining_the.html MAKE SURE YOU USE THE /DETAILED SWITCH OR IT WONT RETURN THE CHANGESET. I had to look at the code for the task and figure out how it was parsing the output from tf.exe to figure this out.

TfsClient 的代码在这里供参考:https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Tfs/TfsClient.cs

Code for TfsClient is here for reference: https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Tfs/TfsClient.cs

这篇关于tfspreview 上的 tf.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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