2016-08-02 36 views
0

我需要找出Team Foundation存储库中每个集合模块内有多少标签。 我正在使用TFS 2013. 我知道我们可以从Visual Studio中获得它。但是我们需要一个脚本来获取标签的数量作为输出。 任何人都可以帮助我获得一个C#或Powershell代码来获得相同的?TFS存储库模块中的标签总数

TIA

+0

你尝试过这么远吗?请阅读:http://stackoverflow.com/help/how-to-ask –

回答

1

您可以使用.NET客户端库得到这个:.NET client libraries for Visual Studio Team Services (and TFS)

代码示例:

using System; 
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.VersionControl.Client; 

namespace GetLabels 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string tfscollection = "http://xxx:8080/tfs/defaultcollection"; 
      TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(tfscollection)); 
      VersionControlServer vcs = ttpc.GetService<VersionControlServer>(); 
      string labelname = null; 
      string labelscope = "$/"; 
      string owner = null; 
      bool includeitem = false; 
      int labelnumber; 
      VersionControlLabel[] labels = vcs.QueryLabels(labelname,labelscope,owner,includeitem); 
      labelnumber = labels.Length; 
      Console.WriteLine(labelnumber); 
      Console.ReadLine(); 
     } 
    } 
} 
+0

以类似的方式,是否有任何代码获取集合中每个模块的当前大小? –