tags:

views:

195

answers:

2

A call like this requires the server name or url:

TeamFoundationServerFactory.GetServer("mytfsserver");

Likewise, I can use the following to get a list of available servers or server names:

TeamFoundationServer[] servers = RegisteredServers.GetServers();
string[] serverNames = RegisteredServers.GetServerNames();

But how do I get the default server that Team Explorer uses to connect?

Alternatively, if I could get the current workspace I think I could use that to get the correct TeamFoundationServer to connect with. However, I want to be able to do this before a solution is loaded which means I do not have a file to use for querying what workspace it belongs in.

A: 

Not sure about default (which is simply the server Team Explorer was connected to the last time VS saved its configuration), but you can get the server with a mapping to the current folder.

var wsp = Microsoft.TeamFoundation.VersionControl.Client.Workstation.GetLocalWorkspaceInfo(path)
var server = wsp.ServerUri
Richard
+1  A: 

See the following: http://blogs.msdn.com/hippietim/archive/2006/03/29/563988.aspx

Chris Lively