How do you get the default TFS Server from Team Explorer?

半世苍凉 提交于 2019-12-11 07:59:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!