How do I get a list of connected TFS projects in Visual Studio?
Using the Visual Studio 2010 and TFS 2010 SDK, I want to get the list of projects in the current collection that the user has selected.
How do I do this?
I can get the collection uri with this code, but not the projects:
TeamFound开发者_开发问答ationServerExt tfsExt =
(TeamFoundationServerExt)Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");
if (tfsExt == null) return;
var activeTfsUri = tfsExt.ActiveProjectContext.DomainUri;
Try this:
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(tpcURI);
ICommonStructureService css = tpc.GetService<ICommonStructureService>();
ProjectInfo[] projects = css.ListProjects();
It should give you the name, uri and the status of the projects.
精彩评论