【问题标题】:Retrieving a TFS project description检索 TFS 项目描述
【发布时间】:2014-02-24 14:05:04
【问题描述】:

我需要从现有的 TFS 2012 安装中收集信息,管理员将一些有用的数据放入团队项目描述中。

我认为检索它会很容易,但我看不到 Microsoft.TeamFoundation.WorkItemTracking.Client.Project 或 Microsoft.TeamFoundation.Server.ProjectInfo 的任何属性公开的这些数据。 想查询Collection数据库,但是表tbl_projects和tbl_project_properties没有描述数据。

【问题讨论】:

    标签: tfs team-project


    【解决方案1】:

    我相信 Microsoft.TeamFoundation.Framework.Client.CatalogResource 类具有您正在寻找的 Description 属性。下面的代码连接到 TFS 配置服务器,然后写出项目集合和团队项目名称和描述。

        private static void WriteOutTeamProjects()
        {
            // 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 = new Uri("http://vsalm:8080/tfs/");
    
            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);
                    Console.WriteLine("  Description: " + projectNode.Resource.Description);
                }
            }
    
            Console.WriteLine("Press any key to finish...");
            Console.ReadKey();
        }
    

    【讨论】:

    • 很好,与此同时,我发现了对相同数据的 SQL 查询,并发布了另一个答案。
    • 要使用CatalogResourceTypesCatalogQueryOptions,您需要参考Microsoft.TeamFoundation.Server.Core。但是,此程序集在我的系统中不可用。你有什么想法,我能做什么?
    【解决方案2】:

    配置数据库上的这个查询给出了相同的数据。

    SELECT [DisplayName] AS ProjectName, [Description] AS ProjectDescription
    FROM [Tfs_Configuration].[dbo].[tbl_CatalogResource]
    WHERE ResourceType = (
        SELECT [Identifier]
        FROM [Tfs_Configuration].[dbo].[tbl_CatalogResourceType] WHERE [DisplayName] = 'Team Project')
    ORDER BY 1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-27
      • 1970-01-01
      • 1970-01-01
      • 2014-03-04
      相关资源
      最近更新 更多