从TeamCity中的PowerShell脚本调用TF.exe

时间:2016-03-14 12:04:13

标签: powershell tfs teamcity teamcity-9.0

我正在尝试从TeamCity构建配置的Powershell步骤中调用tf.exe

可执行文件通常位于C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe(或类似)。在我的脚本中,我将变量设置为tf.exe的路径,如下所示:

$tfsExe = "%env.ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe" 

我已通过RDP访问构建服务器上验证了tf.exe的存在。我还使用以下命令在PowerShell控制台窗口中调用它

& "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\tf.exe" help

以下列输出作出回应,确认其可访问且正常工作:

Microsoft (R) TF - Team Foundation Version Control Tool, Version 11.0.50727.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Type tf help <command name> for command line description.
Type tf msdn <command name> for full documentation in Microsoft Document Explorer.
Commands:
tf add         Adds new files and folders from a local file system location to Team Foundation version control.
tf branch      Copies an item or set of items, including metadata and version control history, from one location to another on the Team Foundation version control server and in the workspace.

1 个答案:

答案 0 :(得分:0)

这里的问题是脚本是在构建代理而不是构建服务器上执行的。一旦在构建代理上安装了TFS插件,就可以使用tf.exe。