Get All team project from TFS collection

In this post i will show the users how to get all team project and the sub system base on your version control structure.

1. Create new C# project

2. Add team foundation server Dll references as

3. Add button on the form and rename it to Fetch Data.

4.  Double click on the button to write this code,

5. Add the connect method to the form from the last post

6. Based on your version control structure you will get all [baseline] branches like this sample branching structure

7. Add this code the get the information


TeamProject[] _tp = version.GetAllTeamProjects(true); //get all team project from project collection
ArrayList _result = new ArrayList();

foreach (TeamProject team in _tp)
string n = team.Name;
ItemSet _set = version.GetItems(”$/” + n, VersionSpec.Latest, RecursionType.Full, DeletedState.NonDeleted, ItemType.Folder);

foreach (Item i in _set.Items)
int x = i.ServerItem.LastIndexOf(’/');
if (i.ServerItem.Substring(x + 1).ToLower().Equals(”Baseline”)) //Get the BaseLine branches
_result.Add(i.ServerItem.Substring(2, x – 2));


Leave a Reply

Your email address will not be published. Required fields are marked *