如何从TFS获取所有集合

如何使用TFS API从TFS获取集合

请参阅此处了解更多详情。 这是TFS最好的资源之一。

private TfsConfigurationServer configurationServer; configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri); public IList> GetCollections() { //ApplicationLogger.Log("Entered into GetCollections() : "); var collectionList = new List>(); try { configurationServer.Authenticate(); ReadOnlyCollection collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); foreach (CatalogNode collectionNode in collectionNodes) { var collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); if (teamProjectCollection == null) continue; collectionList.Add(new KeyValuePair(collectionId, teamProjectCollection.Name)); } } catch (Exception e) { ApplicationLogger.Log(e); } return collectionList; } 

列表中的每个返回的键值对都包含集合guid和集合名称

Interesting Posts