I'm working on a Visual Studio 2010 add-in, and I'm trying to figure out how to determine the currently connected TFS server. I'm guessing I need to use DTE, but I'm having a brain cramp figuring out where to get the info.
Asked
Active
Viewed 2,112 times
5

jessehouwing
- 106,458
- 22
- 256
- 341

Robaticus
- 22,857
- 5
- 54
- 63
-
It looks like you're actually writing a package, not an add-in. Yes? – Kate Gregory Aug 08 '10 at 18:27
-
I thought a package as a collection of addins? this is the first extension activities I've done with 2010, so I may be a little confused. – Robaticus Aug 08 '10 at 19:52
-
any solution for get TFS Connection in Addin ? – Kiquenet Jul 13 '11 at 11:58
-
Thanks bro, would have taken me forever to find this – Jason Dec 03 '12 at 15:34
-
Thank you very much! Saved me a lot of hours. – Marian Zagoruiko Oct 10 '13 at 16:04
2 Answers
2
I suggest you check out the Microsoft.TeamFoundation.VersionControl.Client.Workstation.GetLocalWorkspaceInfo
method, in result you have an object and access ServerUri property

jessehouwing
- 106,458
- 22
- 256
- 341

Aghilas Yakoub
- 28,516
- 5
- 46
- 51
1
Robaticus originally edited the question with the solution. Converted it to a Community Wiki answer:
Actually, I may have found the answer, which I culled from a couple places.
var dte = Package.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
TeamFoundationServerExt ext = dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
TeamFoundationServer tfs = new TeamFoundationServer(ext.ActiveProjectContext.DomainUri);
VersionControlServer vcs = tfs.GetService<VersionControlServer>();
var changes = vcs.GetPendingChanges(null);

jessehouwing
- 106,458
- 22
- 256
- 341