如何以编程方式在 TFVC 中添加挂起的更改或签出文件 (netstandard2.0)

How to add pending changes or checkout files in TFVC programmatically (netstandard2.0)

我们之前使用的包(Microsoft.TeamFoundationServer.ExtendedClient), doesn't support netstandard2.0 and it seems that the new REST APIs也不支持我们想要完成的任务。

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

TF.exe 应该能够完成上述任务,但要获得通往它的路径,我们不知何故需要 vsWhere.exe,因此整个方法似乎有点麻烦。

没有,将来也不会有 .NET Core 兼容版本的 TFVC 客户端对象模型。用于与 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 中这样做,以便在打包我的应用程序之前将最新版本注入我的构建目录。

这是我之后使用的代码 find tf.exe:

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