How to List TFS Team Projects using the API

June 18, 2006 at 2:57 am | In Team Foundation Server |

As part of my TFS Bug Snapper tool I couldn’t work out how to bring up the standard “Select Server / Team Project” dialog, so I did what all good developers would do - I reinvented the wheel.

See James Manning’s post on “Listing the Team Projects on a Server” for the bits to make this happen. You can download his source here.

Essentially it comes down to this:

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(args[0]);

ICommonStructureService css = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));

foreach (ProjectInfo projectInfo in css.ListAllProjects())

  // do stuff

1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. When working with WorkItems (as it appears that you were), it may be easier to use the Projects property of the WorkItemStore, as you might already have a reference to it:Using tfs As TeamFoundationServer = TeamFoundationServerFactory.GetServer("myserver")Dim witstore As WorkItemStore = tfs.GetService(GetType(WorkItemStore))For Each proj As Project In witstore.Projects ‘ do stuffNextEnd Using

    Comment by Burton — January 17, 2007 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.