3

On how to get the collections from TFS refer here

Please refer here for more details. This is one of the best resources on TFS stuff.

Community
  • 1
  • 1
Martin
  • 3,396
  • 5
  • 41
  • 67

2 Answers2

3

The collection guid is passed in and the list returns the name of all projects in that particular collection.

    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;
}
Martin
  • 3,396
  • 5
  • 41
  • 67
1

you can do this now via the rest api. e.g.

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

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

timB33
  • 1,977
  • 16
  • 33