3

关于如何从 TFS 获取集合,请参阅此处

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

4

2 回答 2

3

传入集合 guid,列表返回该特定集合中所有项目的名称。

    public IList<string> GetProjectsFormCollection(Guid collectionId)
{
    ICommonStructureService structureService = null;
    try
    {
        TfsTeamProjectCollection teamProjectCollection =
            _configurationServer.GetTeamProjectCollection(collectionId);
        teamProjectCollection.Authenticate();
        structureService =
            (ICommonStructureService)teamProjectCollection.GetService(typeof(ICommonStructureService));
    }
    catch (Exception e)
    {
        ApplicationLogger.Log(e);
    }

    var projectInfoList = new List<ProjectInfo>(structureService.ListAllProjects());
    IEnumerable<string> data = projectInfoList.Select(proj => proj.Name);
    List<string> list = data.ToList();
    return list;
}
于 2013-04-19T09:37:38.570 回答
1

您现在可以通过其余 api 执行此操作。例如

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects?api-version=1.0 

来自:https ://www.visualstudio.com/en-us/docs/integrate/api/tfs/projects

于 2017-07-03T10:47:00.627 回答