TFS API Part 50 – Get Team Project Template


In my last post TFS 2012 Upgrade Process Template–Guide I’ve talked about upgrading an existing Team Project Template to another or a newer template.

An important part of the upgrading process is knowing from what template you are upgrading from – although this is not really important because the base template can be modified completely.

So here is a simple tool to display the Base Process Template name.


Download Demo Project

Step 1: Connect TFS and Getting Team Projects

Create WPF Application, and add the basic code for connecting TFS and collecting all Team Projects under that collection.

The below code use ICommonStructureService to retrieve all Projects under that collection.

var tpp = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false);


if (tpp.SelectedTeamProjectCollection == null) return;
_tfs = tpp.SelectedTeamProjectCollection;

_ics = _tfs.GetService<ICommonStructureService>();

listProjects.ItemsSource = _ics.ListAllProjects();

Step 2: Get Team Project Details

Now once you got all the team projects under our collection, we want to get the project properties that will show us the creation process template.

private void listProjects_SelectionChanged(object sender, SelectionChangedEventArgs e)
    if (listProjects.SelectedItem == null) return;

    var selectedProject = listProjects.SelectedItem as ProjectInfo;

    string name = "";
    string state = "";
    int templateId = 0;
    ProjectProperty[] projectProperties;

    _ics.GetProjectProperties(selectedProject.Uri, out name, out state, out templateId, out projectProperties);

    var properties = projectProperties.Aggregate("", (current, p) => current + string.Format("Name: {0}  -  Value: {1}", p.Name, p.Value));

    txtProjectDetails.Text = string.Format("Project Name: {0} \nState:{1}\n:Properties:{2}", name, state, properties);

Download Demo Project

Add comment
facebook linkedin twitter email

Leave a Reply