TFS存储库的模块内的标签总数

本文关键字:标签 模块 存储 TFS | 更新日期: 2023-09-27 17:59:44

我需要了解Team Foundation存储库中集合的每个模块中有多少标签。我正在使用TFS 2013。我知道我们可以从Visual Studio获得它。但我们需要一个脚本,它可以为我们提供作为输出的标签数量。有人能帮我获得C#或Powershell代码吗?

TIA

TFS存储库的模块内的标签总数

您可以使用.NET客户端库来获得以下内容:Visual Studio Team Services(和TFS)的.NET客户端库

代码示例:

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();
        }
    }
}