【问题标题】:How to connect VS to TFS Team Project from VSSDK如何从 VSSDK 将 VS 连接到 TFS 团队项目
【发布时间】:2013-05-24 07:18:54
【问题描述】:
ITeamFoundationContextManager tfContextManager = ServiceProvider.GlobalProvider.GetService(typeof(ITeamFoundationContextManager)) as ITeamFoundationContextManager;
tfContextManager.SetContext(teamProjectCollection, projectUri);

此代码不起作用。麻烦

【问题讨论】:

  • 什么“不起作用”? tfContextManager 是否返回 null?调用抛出异常...?

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


【解决方案1】:

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

}

【讨论】:

  • 我很确定他是在尝试更改 VS 中的上下文,而不是连接到任意服务器。
猜你喜欢
  • 2018-11-06
  • 1970-01-01
  • 2016-01-02
  • 2013-05-30
  • 2011-10-15
  • 1970-01-01
  • 1970-01-01
  • 2011-07-03
  • 2020-04-28
相关资源
最近更新 更多