TFS2010 API: Retrieving a list of Process Templates on the server.

Posted by Stuart Preston on November 7, 2009 under Team Foundation Server | 2 Comments to Read

I thought I’d post some utility code that I’ve been playing with to retrieve information about the Process Templates available on a TFS 2010 instance.

As you can see from the code, each TeamProjectCollection has its own store of Process Templates (in TFS 2008 there was in effect a single “Project Collection”) so we need to look through each collection to retrieve the templates that have been uploaded to it.

You’ll need references to Microsoft.TeamFoundation.dll, Microsoft.TeamFoundation.Client.dll, Microsoft.TeamFoundation.Common.dll.  On a machine with Visual Studio 2010 installed they should be found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 or C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 depending on whether you have a 64-bit version of Windows or not.  You’ll also need to set the Target Framework to .NET Framework 3.5 as the assemblies required are in the v2 GAC.

This code will work against TFS2010 Beta 2 but is not guaranteed to work in the RTM.

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

namespace TFSUtils
{
    class Program
    {
        static void Main(string[] args)
        {
            //replace this with the URL to your TFS instance.
            Uri tfsUri = new Uri("http://sptfs02:8080/tfs");

            TeamFoundationApplicationInstance tfai = new TeamFoundationApplicationInstance(tfsUri, new UICredentialsProvider());
            tfai.EnsureAuthenticated();

            ITeamProjectCollectionService collectionService = tfai.GetService<ITeamProjectCollectionService>();
            IList<TeamProjectCollection> collections = collectionService.GetCollections();

            foreach (TeamProjectCollection collection in collections)
            {
                if (collection.State == TeamFoundationServiceHostStatus.Started)
                {
                    Console.WriteLine(String.Format("\nCollection: {0}", collection.Name));
                    IProcessTemplates processTemplates = tfai.GetTeamFoundationServer(collection.Id).GetService<IProcessTemplates>();
                    TemplateHeader[] templateHeaders = processTemplates.TemplateHeaders();
                    foreach (TemplateHeader header in templateHeaders)
                    {
                        Console.WriteLine(String.Format("\t{0} {1}", header.TemplateId, header.Name));
                    }
                }
            }

            Console.WriteLine("\nPress any key to continue.");
            Console.ReadKey();
        }
    }
}

See you at PDC 2009?

Posted by Stuart Preston on October 23, 2009 under Team Foundation Server | Be the First to Comment

imageI will be presenting at Microsoft PDC 2009 along with Simon Bennett from EMC Consulting on Scrum for Microsoft Visual Studio Team System.

It will be very weird presenting with an ex-colleague and seeing a few folk I used to work with, but I’m looking forward to it and meeting all sorts of interesting people with stories to tell about their experience with the Scrum for Team System process template (I worked on this since the first Beta of Team Foundation Server 2005 right up to when I left EMC last month).

We’re going to do a drill down into the new features that have been implemented in the latest version that is compatible with Visual Studio 2010 Team Foundation Server Beta 2, and share our experience of extending Team Foundation Server.

Look forward to seeing some of you there!

PS: There’s still a $300 discount if you register before the end of October.

New blog site

Posted by Stuart Preston on October 13, 2009 under Personal, Team Foundation Server | 2 Comments to Read

Welcome to my new home on the web.  I’ve been blogging for over 5 years at http://consultingblogs.emc.com/stuartpreston and will aim to continue here and keep those permalinks permanent.

I’m sure the range of topics on here will vary but for now will mostly be around Team Foundation Server, Application Lifecycle Management and life as an ex-CTO :)  Yes as it’s my own blog I’ll be mixing some of my personal observations on life in with the work stuff too…

If you followed me here from my last blog at EMC Consulting and just want the new feed address, it is: http://stuartpreston.net/blog/?feed=rss2