【问题标题】:How to add pending changes or checkout files in TFVC programmatically (netstandard2.0)如何以编程方式在 TFVC 中添加挂起的更改或签出文件(netstandard2.0)
【发布时间】:2021-11-21 03:52:29
【问题描述】:

我们之前使用的包(Microsoft.TeamFoundationServer.ExtendedClient)不支持netstandard2.0,新的REST APIs似乎也不支持我们想要完成的任务。

那么当定位netstandard2.0 时,在 tfvc 中添加新文件作为待定更改或签出现有文件的推荐方法是什么?

TF.exe 应该能够完成上述任务,但要找到它的路径,我们不知何故需要vsWhere.exe,所以整个方法似乎有点麻烦。

【问题讨论】:

  • Microsoft 自己不再使用 TFVC 的事实应该给您一个非常重要的线索,即它不再受支持并且永远不会再次更新。微软自己已经迁移到 Git 的事实应该会给你一个关于你应该如何处理你的 repos 的非常重要的线索。
  • @IanKemp 感谢您的评论。是的,我知道,我们已经将很多东西移动到 git 存储库中,但是我们有一个巨大的遗留 tfvc 单一存储库,我们不能那么容易地移动。

标签: c# .net-core azure-devops tfvc .net-standard-2.0


【解决方案1】:

TFVC 客户端对象模型没有,也不会是 .NET Core 兼容版本。用于与 TFVC 交互的 API 是基于 SOAP 的 API,从未移植到 REST。

您可以使用 vswhere 查找 tf.exe 或使用客户端对象模型构建自定义 .NET 4.x 可执行文件并从您的 .NET Core 应用程序调用。

您可以在您的应用程序中重新分发 vswhere 的副本。您可以从这里获取最新版本:

    - powershell: |
        $vswhereLatest = "https://github.com/Microsoft/vswhere/releases/latest/download/vswhere.exe"
        $vswherePath = "$(Build.SourcesDirectory)\tools\vswhere.exe"
        remove-item $vswherePath
        invoke-webrequest $vswhereLatest -OutFile $vswherePath
        test-path $vswherePath -PathType Leaf
      displayName: 'Grab the latest version of vswhere.exe'

如您所见,我在我的 Azure Pipeline 中运行此程序,以便在打包我的应用程序之前将最新版本注入我的构建目录。

这是我之后使用的代码找到tf.exe

$path = & $PSScriptRoot/vswhere.exe -latest -products * `
  -requires Microsoft.VisualStudio.TeamExplorer `
  -find "Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe"

【讨论】:

  • vswhere.exe 的参数甚至可以改进,所以它会产生一个单行:-latest -products * -requires Microsoft.VisualStudio.TeamExplorer -find "**\Team Explorer\TF.exe"
  • @roli09 感谢您的更新。我发现** 需要永远。所以确切的路径会更好:)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-04-25
  • 2013-01-28
  • 1970-01-01
  • 2015-04-12
  • 1970-01-01
  • 2013-11-12
  • 2015-10-15
相关资源
最近更新 更多