如何从VSSDK连接VS到TFS团队项目

本文关键字:TFS 团队 项目 VS 连接 VSSDK | 更新日期: 2023-09-27 18:15:12

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

这段代码不起作用。请

如何从VSSDK连接VS到TFS团队项目

我不是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)
{
}