TFS API Part 3: Get Project List Using ICommonStructureService
TFS API Part 3: Get Project List Using ICommonStructureService
In the first post about TFS API Part 1: Domain Picker we saw how to take TFS projects only by selecting them in the Domain Project Picker.
In the post I’ll saw how to take all project from the TFS Server.
Download Demo Project
First add reference for Microsoft.TeamFoundation,Microsoft.TeamFoundation.Client
located in - C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
Add using for Proxy,Client and Server.
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Proxy;
using Microsoft.TeamFoundation.Server;
Connect to TFS Server
DomainProjectPicker dp = new DomainProjectPicker(DomainProjectPickerMode.None);
dp.ShowDialog();
After selecting the desire TFS I’ll make TeamFoundationServer object:
TeamFoundationServer tfs = dp.SelectedServer;
Create ICommonStructureService object that will take TFS Structure Service.
ICommonStructureService structureService = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));
Use ListAllProjects method to get all Team Projects in the TFS.
ProjectInfo[] projects = structureService.ListAllProjects();
list_projects.DataSource = projects;

Download Demo Project