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
One Comment
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