问题
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.
回答1:
See the following: http://blogs.msdn.com/hippietim/archive/2006/03/29/563988.aspx
回答2:
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
来源:https://stackoverflow.com/questions/628090/how-do-you-get-the-default-tfs-server-from-team-explorer