如何从VSSDK连接VS到TFS Team Project

时间:2013-05-24 07:18:54

标签: c# tfs visual-studio-extensions visual-studio-sdk

ITeamFoundationContextManager tfContextManager = ServiceProvider.GlobalProvider.GetService(typeof(ITeamFoundationContextManager)) as ITeamFoundationContextManager;
tfContextManager.SetContext(teamProjectCollection, projectUri);

此代码不起作用。 PLZ

1 个答案:

答案 0 :(得分:0)

我不是100%肯定你在这里问的是什么,但我已经做了一些使用SDK连接到TFS的代码,这可能对你有所帮助:

 private TfsTeamProjectCollection tfsServer = null;
 private VersionControlServer vcsServer = null;

 // This code is in a connection method
 tfsServer = new TfsTeamProjectCollection(new Uri (pServerName));
 tfsServer.EnsureAuthenticated();
vcsServer = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer));

然后,您可以使用以下内容提取团队项目集合:

// attempt to extract a list of all projects

TeamProject[] projects = vcsServer.GetAllTeamProjects(true);

// add each one in turn to the list

foreach (TeamProject currentProject in projects)
{

}