Powershell 和 TFS:tf.exe 与 Power tools TFS cmdlet 对比?

发布于 2024-10-16 02:34:21 字数 304 浏览 2 评论 0原文

我正在创建一个脚本来在我的 TFS 实例中执行大量移动。我有 2010 TFS Power Tools 提供的 tfs cmdlet,但它们的获取帮助文档非常稀疏。具体来说,Add-TfsPendingChange 似乎不支持重命名,这迫使我改用“tf.exe rename”。

首先:我是否错过了 cmdlet 的文档?我已经尝试过在命令上获取帮助,但它们不支持 -detailed 或 -examples 标志。还有什么可用的吗?

其次:为什么我必须选择任何 cmdlet 而不是常规 tf.exe?在执行类似功能时,除了通过管道传递对象之外还有其他好处吗?

I'm in the middle of creating a script to do large amount of moves in my TFS instance. I have the tfs cmdlets available with the 2010 TFS Power Tools, but the get-help documentation for them is very sparse. Specifically, Add-TfsPendingChange doesn't seem to support rename, which forces me to use "tf.exe rename" instead.

First off: have I somehow missed the documentation for the cmdlets? I've tried get-help on the commands, but they don't support -detailed or -examples flags. Is anything more available?

Secondly: what reason do I have to prefer any of the cmdlets over regular tf.exe? Are there benefits other than passing objects through the pipe when performing similar functions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清旖 2024-10-23 02:34:21

目前,TF cmdlet 是一种简约的产品,其中包括提供的文档。一般来说,我会使用 TF cmdlet,它们支持我想要做的事情 - 特别是如果您有任何疑问。处理查询 cmdlet 的输出要容易得多,因为它们为您提供丰富的对象,而不是在使用诸如 tf status 之类的内容时必须解析的文本流。 /r。

另请记住,在 x64 Windows 系统上,TF cmdlet 仅适用于 32 位 PowerShell 主机。

The TF cmdlets are a bit of a minimalistic offering at this point and that includes the provided documentation. In general I would use the TF cmdlets where they support what I'm trying to do - especially if you have any queries. Processing the output of the query cmdlets is much easier because they give you rich objects instead of the text stream you have to parse when using something like tf status . /r.

Also keep in mind that on a x64 Windows system, the TF cmdlets only work in a 32-bit PowerShell host.

蓝颜夕 2024-10-23 02:34:21

tf cmdlet 并不是完全无用,但是......我们决定现在不尝试在我们的构建环境中使用它们,即使这意味着文本解析。

除了 x64 之外,还有很多缺少命令(感谢@Keith)和缺少参数,并且最重要的是,它们在远程会话中不起作用!

The tf cmdlets are not exactly useless, but ... we decided against trying to use them in our build environment right now, even though it means text-parsing.

Aside from the x64 thing, there are lots of missing commands (thanks @Keith) and missing parameters, and most importantly, they don't work in remote sessions!

你是我的挚爱i 2024-10-23 02:34:21

第三种选择是使用 PowerShell 中的 TFS 公共程序集。执行此操作时,您可以访问所有 TFS 客户端功能,并且仍然可以使用 TFS cmdlet。您是否选择此方法而不是 tf.exe 和其他 TFS 命令行可执行文件取决于您喜欢哪种脚本编写环境。

以下是引用 TFS 2013 公共程序集的 PowerShell 命令(对于 TFS 2012 或 2010,只需将 Version=12.0.0.0 更改为 Version=11.0.0.0Version =10.0.0.0)。

'Microsoft.TeamFoundation.Client', 'Microsoft.TeamFoundation.Common', 'Microsoft.TeamFoundation.VersionControl.Client' |
    ForEach-Object {
        Add-Type -AssemblyName "$_, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    }

对于重命名示例,您可以:

  1. 使用 Get-TfsWorkspace cmdlet 实例化
    Microsoft.TeamFoundation.VersionControl.Client.Workspace 对象。
  2. 调用 Workspace 对象的 PendRenameGetPendingChanges签入方法。

像这样的事情:

$workspace = Get-Workspace
$workspace.PendRename($oldItemPath, $newItemPath)
$pendingChange = $workspace.GetPendingChanges($oldItemPath)
$workspace.Checkin($pendingChange, $comment)

A third option is to use the TFS public assemblies from within PowerShell. When you do this, you can access all TFS client capabilities and still use TFS cmdlets as well. Whether you choose this approach over tf.exe and the other TFS command-line executables depends on which scripting environment you prefer.

Here is a a PowerShell command to reference the TFS 2013 public assemblies (for TFS 2012 or 2010 just change Version=12.0.0.0 to Version=11.0.0.0 or Version=10.0.0.0).

'Microsoft.TeamFoundation.Client', 'Microsoft.TeamFoundation.Common', 'Microsoft.TeamFoundation.VersionControl.Client' |
    ForEach-Object {
        Add-Type -AssemblyName "$_, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    }

For your renaming example, you could then:

  1. Use the Get-TfsWorkspace cmdlet to instantiate a
    Microsoft.TeamFoundation.VersionControl.Client.Workspace object.
  2. Call the Workspace object's PendRename, GetPendingChanges and Checkin methods.

Something like this:

$workspace = Get-Workspace
$workspace.PendRename($oldItemPath, $newItemPath)
$pendingChange = $workspace.GetPendingChanges($oldItemPath)
$workspace.Checkin($pendingChange, $comment)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文