以编程方式获取TFS责备(注释)数据

我正在尝试为Team Foundation Server 2010实现一个插件,该插件将创建有关团队项目中用户的报告。 从概念上讲,为了正确实现此插件,我所需要的只是访问在Visual Studio中使用“注释”function时获得的相同数据: 我需要能够告诉谁是最后一个创作给定行的人代码

我在互联网上浏览了文档或代码示例,但我能找到的所有建议都是建议,例如使用TFS命令行工具或看似不完整的代码示例 。

我不介意在客户端代码中做很多繁重的工作,但似乎没有一种明显的方法可以获得有关Changeset中代码内容的有用作者数据,也不会从合并详细信息返回中获取。

与此同时,我找到了一个可以执行Team Foundation Power Tools流程并解析其输出的工作解决方案:

private readonly Regex m_Regex = new Regex(@"^(?\d+)(?.*)", RegexOptions.Compiled | RegexOptions.Multiline); public List GetAnnotations(string filepath, string codeText) { var versionControlServer = CreateVersionControlServer(); return m_Regex.Matches(ExecutePowerTools(filepath)) .Cast() .Where(m => m.Groups["codeLine"].Value.Contains(codeText)) .Select(v => versionControlServer.GetChangeset(int.Parse(v.Groups["changeset"].Value), false, false)) .ToList(); } private static VersionControlServer CreateVersionControlServer() { var projectCollection = new TfsTeamProjectCollection(new Uri(@"TFS URL")); var versionControlServer = projectCollection.GetService(); return versionControlServer; } private static string ExecutePowerTools(string filepath) { using (var process = Process.Start(TfptLocation, string.Format("annotate /noprompt {0}", filepath))) { process.WaitForExit(); return process.StandardOutput.ReadToEnd(); } } 

我有一个非常相似的要求,以获取文件中特定属性的详细信息,例如谁添加,何时,相关的工作项等; 以下GitHub项目正在实施以获取所需的详细信息并且需要对工作进行最小的更改 –

SonarQube SCM TFVC插件

它需要从安装了Team Foundation Server对象模型的Windows计算机执行分析(下载TFS 2013)。