C# 使用c控制台应用程序连接到TFS服务器

C# 使用c控制台应用程序连接到TFS服务器,c#,tfs,C#,Tfs,我正在开发一个c控制台应用程序,希望在其中连接到TFS服务器并从中访问信息 我的TFS服务器是: 基本上,我们通过TFS维护一个票务系统,我想访问票务的服务名称 以上是我的TFS系统的一个剪辑。< p>您可以编程连接到运行Team Foundation的服务器,然后使用Client API来访问该服务器上的团队项目,如以下示例: using System; using System.Collections.ObjectModel; using Microsoft.TeamFoundation.C

我正在开发一个c控制台应用程序,希望在其中连接到TFS服务器并从中访问信息

我的TFS服务器是:

基本上,我们通过TFS维护一个票务系统,我想访问票务的服务名称


以上是我的TFS系统的一个剪辑。

< p>您可以编程连接到运行Team Foundation的服务器,然后使用Client API来访问该服务器上的团队项目,如以下示例:

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

更多详细信息请参考MSDN中的本教程:

您好,欢迎来到StackOverflow。请花些时间阅读帮助页面,特别是命名和的部分。更重要的是,请阅读。您可能还想了解。请告诉我如何连接到tfs实例并从中访问工作项?您提供的屏幕截图中的内容是查询,而不是工作项。您希望通过C$控制台应用程序获得什么?查询或工作项?我基本上希望访问ID和其他各种列之类的字段。。