Question

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.

Was it helpful?

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top