Tfs Team Foundation服务器SDK示例

Tfs Team Foundation服务器SDK示例,tfs,sdk,Tfs,Sdk,有人能告诉我TFS SDK的C#样本吗 我到处寻找,似乎找不到示例或SDK。您可以看看哪些示例和所有名称空间 下面的示例演示如何以编程方式连接到正在运行Team Foundation的服务器,然后访问团队项目、列出项目信息。 using System; using System.Collections.ObjectModel; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.Framework.Comm

有人能告诉我TFS SDK的C#样本吗

我到处寻找,似乎找不到示例或SDK。

您可以看看哪些示例和所有名称空间

下面的示例演示如何以编程方式连接到正在运行Team Foundation的服务器,然后访问团队项目、列出项目信息。

using System;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Client;

namespace TfsApplication
{
    class Program
    {
        static void Main(String[] args)
        {
            // Connect to Team Foundation Server
            //     Server is the name of the server that is running the application tier for Team Foundation.
            //     Port is the port that Team Foundation uses. The default port is 8080.
            //     VDir is the virtual path to the Team Foundation application. The default path is tfs.
            Uri tfsUri = (args.Length < 1) ? 
                new Uri("http://Server:Port/VDir") : new Uri(args[0]);

            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

            // Get the catalog of team project collections
            ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
                new[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            // List the team project collections
            foreach (CatalogNode collectionNode in collectionNodes)
            {
                // Use the InstanceId property to get the team project collection
                Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);

                // Print the name of the team project collection
                Console.WriteLine("Collection: " + teamProjectCollection.Name);

                // Get a catalog of team projects for the collection
                ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
                    new[] { CatalogResourceTypes.TeamProject },
                    false, CatalogQueryOptions.None);

                // List the team projects in the collection
                foreach (CatalogNode projectNode in projectNodes)
                {
                    Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
                }
            }
        }
    }
}
使用系统;
使用System.Collections.ObjectModel;
使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.Framework.Common;
使用Microsoft.TeamFoundation.Framework.Client;
命名空间应用程序
{
班级计划
{
静态void Main(字符串[]参数)
{
/ /连接到Team Foundation服务器
//Server是运行Team Foundation应用程序层的服务器的名称。
//Posits是Team Foundation使用的端口。默认端口为8080。
// VDir是Team Foundation应用程序的虚拟路径。默认路径是TFS。
Uri tfsUri=(args.Length<1)?
新Uri(“http://Server:Port/VDir“”:新的Uri(args[0]);
TfsConfigurationServer配置服务器=
TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);
//获取团队项目集合的目录
ReadOnlyCollection collectionNodes=configurationServer.CatalogNode.QueryChildren(
新[]{CatalogResourceTypes.ProjectCollection},
错误,目录查询选项。无);
//列出团队项目集合
foreach(collectionNodes中的CatalogNode collectionNode)
{
//使用InstanceId属性获取团队项目集合
Guid collectionId=新Guid(collectionNode.Resource.Properties[“InstanceId”]);
TfsTeamProjectCollection teamProjectCollection=configurationServer.GetTeamProjectCollection(collectionId);
//打印团队项目集合的名称
Console.WriteLine(“Collection:+teamProjectCollection.Name”);
//获取集合的团队项目目录
ReadOnlyCollection projectNodes=collectionNode.QueryChildren(
新[]{CatalogResourceTypes.TeamProject},
错误,目录查询选项。无);
//列出集合中的团队项目
foreach(项目节点中的CatalogNode项目节点)
{
Console.WriteLine(“团队项目:+projectNode.Resource.DisplayName”);
}
}
}
}
}
一些精彩的博客,包括多个API示例供您参考:

  • < P>(即使样本为C++,仍然非常有用)