Listing the process templates on a TFS server

Buck Hodges

In response to a forum question about how to list the process templates on the server, Tony Edwards, a developer on Work Item Tracking, posted the following code snippet showing how to do it.  The TeamFoundationServer object provides a number of services, including one for dealing with process templates.

Here is  a simple console program to list the templates.  IProcessTemplate has members that return XML – you could bind that to the grid.  You would invoke the sample below as follows:

templateheaders http://<your_server>:8080

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Client;


namespace TemplateHeaders
{
    class Program
    {
        static void Main(string[] args)
        {
           
            TeamFoundationServer tfs = new TeamFoundationServer(args[0]);
            IProcessTemplates templates =
                (IProcessTemplates) tfs.GetService(typeof(IProcessTemplates));
            TemplateHeader [] headers = templates.TemplateHeaders();
            foreach (TemplateHeader header in headers)
            {
                Console.WriteLine(header.Name);
            }
        }
    }
}

If you haven’t built a code sample before, you can find instructions on adding the TFS assemblies to the .NET tab in VS here.

0 comments

Leave a comment

Feedback usabilla icon