在Powershell中使用tf.exe说所有文件都是最新的

时间:2016-05-26 15:27:44

标签: powershell tfs

我使用Powershell从TFS获取最新的构建标签,然后将最新的构建标签提取到特定目录中。

获取最新的构建标签可以正常工作,如下所示:

Set-Location -Path 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\'
$cmd = '.\tf.exe'
$arg1 = 'labels'
$arg2 = '/owner:*'
$arg3 = 'BLD_V3R11*'
$result = & $cmd $arg1 $arg2 $arg3 | Select-Object -Last 1

$ result将等于

BLD_V3R11_1234

所以现在我尝试从这个版本中获取所有文件,如c:\ Compile文件夹

Set-Location -Path 'c:\Compile'
$cmd = 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe'
$arg1 = 'get'
$arg2 = 'c:\Compile2\*'
$arg3 = '/recursive'
$arg4 = '/version:L' + $result
& $cmd $arg1 $arg2 $arg3 $arg4

但是,没有文件从TFS中提取,并且调用返回“所有文件都是最新的。”

如果c:\ Compile中没有文件,文件如何是最新的?

1 个答案:

答案 0 :(得分:0)

错误“所有文件都是最新的”通常在文件夹不存在时发生,您可以指定要检索的文件或文件夹的服务器路径,例如$arg2 = '$/teamProject/project/file.cs'