2

I'm about to write a Visual Studio Add-In (target environment: VS2010) that should enable the user to perform some work item related tasks. How can I get the TFS project that is currently active in Team Explorer? Can I subscribe to an event that informs me when the current project collection is changed?

Thanks,

Markus

Markus
  • 20,838
  • 4
  • 31
  • 55

1 Answers1

6

For a standard VS add-in project:

When the add-in is connected, the DTE-object is provided and stored in the variable _applicationObject. The method GetObject can be used to retrieve the current TFS connection data (project collection url, project name):

TeamFoundationServerExt tfsConn = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;

In order to use the TeamFoundationServerExt class, a reference to the assembly Microsoft.VisualStudio.TeamFoundation is required. It is located in:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.TeamFoundation.dll.

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
Markus
  • 20,838
  • 4
  • 31
  • 55