【问题标题】:How to get the name of all projects in a TFS collection?如何获取 TFS 集合中所有项目的名称?
【发布时间】:2013-04-19 09:37:38
【问题描述】:

关于如何从 TFS 获取集合请参考 here

详情请咨询here。这是关于 TFS 的最佳资源之一。

【问题讨论】:

    标签: c# tfs alm


    【解决方案1】:

    传入集合 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;
    }
    

    【讨论】:

    • 你这里的 对象是什么?
    【解决方案2】:

    您现在可以通过 rest 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      • 2011-07-11
      • 2011-01-18
      相关资源
      最近更新 更多