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

查看:96
本文介绍了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上找到,但是带有解决方案的解决方案似乎不适用于TFS2010.我只花了整整一整天都在撞墙: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 ChangeSetNumber:41

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

YAHOO!

收到马丁·伍德沃德(Martin Woodward)的命令: http://www.woodwardweb.com/vsts/determining_the.html 确保使用/DETADLED开关,否则它不会返回更改集.我不得不看一下该任务的代码,并弄清楚它是如何解析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天全站免登陆