<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stuartpreston.net &#187; Process</title>
	<atom:link href="http://stuartpreston.net/blog/tag/process/feed/" rel="self" type="application/rss+xml" />
	<link>http://stuartpreston.net/blog</link>
	<description>Blog of Stuart Preston</description>
	<lastBuildDate>Sun, 23 Oct 2011 09:34:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TFS2010 API: Retrieving a list of Process Templates on the server.</title>
		<link>http://stuartpreston.net/blog/2009/11/07/tfs2010-api-retrieving-a-list-of-process-templates-on-the-server/</link>
		<comments>http://stuartpreston.net/blog/2009/11/07/tfs2010-api-retrieving-a-list-of-process-templates-on-the-server/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 16:11:25 +0000</pubDate>
		<dc:creator>Stuart Preston</dc:creator>
				<category><![CDATA[Team Foundation Server]]></category>
		<category><![CDATA[ALM]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[TFS2010]]></category>
		<category><![CDATA[TFS2010 Beta 2]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://stuartpreston.net/blog/?p=12</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>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.</p>
<p>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 <em>or</em> 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.</p>
<p>This code will work against TFS2010 Beta 2 but is not guaranteed to work in the RTM.</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Text;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Framework.Client;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Framework.Common;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Client;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Server;

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

            TeamFoundationApplicationInstance tfai = <span class="kwrd">new</span> TeamFoundationApplicationInstance(tfsUri, <span class="kwrd">new</span> UICredentialsProvider());
            tfai.EnsureAuthenticated();

            ITeamProjectCollectionService collectionService = tfai.GetService&lt;ITeamProjectCollectionService&gt;();
            IList&lt;TeamProjectCollection&gt; collections = collectionService.GetCollections();

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

            Console.WriteLine(<span class="str">"\nPress any key to continue."</span>);
            Console.ReadKey();
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://stuartpreston.net/blog/2009/11/07/tfs2010-api-retrieving-a-list-of-process-templates-on-the-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

