NotDan
NotDan

Reputation: 32233

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:

TeamFoundationServerExt tfsExt =
               (TeamFoundationServerExt)Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");

if (tfsExt == null) return;

var activeTfsUri = tfsExt.ActiveProjectContext.DomainUri;

Upvotes: 1

Views: 1409

Answers (1)

Duat Le
Duat Le

Reputation: 3596

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.

Upvotes: 1

Related Questions