VS2015 以编程方式签出文件

VS2015 Check out files programmatically

我正在使用 VS2015,我尝试从工作区中包含的文件夹中检出文件:我有此映射 D:\tfs 我尝试检查从 D:\tfs\MyProject\Subfolder1 输出文件 我添加了 Microsoft.TeamFoundation.VersionControl.ClientMicrosoft.TeamFoundation.Client v12 作为参考并用于

   TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsServerAddress));
   var versionControl = tfs.GetService<VersionControlServer>();
   var workspace = versionControl.TryGetWorkspace(pathToFolder);

但它不起作用,我总是得到 ItemNotMappedException

这是用于 VS2010 的旧代码,我假设是 TFS2010。 更新的方法是什么?

无法调用API版本independent.You需要使用相同的tfs客户端版本调用API.

请尝试按照以下步骤解决问题:

  1. 删除当前引用 Microsoft.TeamFoundation.VersionControl.Client 和 Microsoft.TeamFoundation.Client
  2. 通过 运行 安装 Microsoft Team Foundation Server Extended Client 程序包管理器控制台中的以下命令

PM > Install-Package Microsoft.TeamFoundationServer.ExtendedClient -Version 15.112.1

然后再试一次。

您也可以参考这个类似的帖子来签出文件: How can I programmatically check-out an item for edit in TFS?