【问题标题】:Need command to get a file from TFS without a workspace需要命令从没有工作区的 TFS 获取文件
【发布时间】:2010-11-13 15:12:21
【问题描述】:

我想要做的是使用命令行(tf.exe 或 powershell)将特定版本的文件从 TFS 获取到我的工作区以外的位置

我想这样做,这样它就不会影响我工作区中的文件,并将文件放入发布文件夹中。

tf.exe 似乎只支持将文件获取到您的工作区。

我也没有找到使用 Powershell 的方法。

谁能帮帮我?

【问题讨论】:

    标签: tfs powershell


    【解决方案1】:
    rem tf.exe
    tf view $/path/to/file.txt /version:1234 > %temp%\file.txt
    
    # powershell
    $tfs = get-tfsserver $hostName -all
    $tfs.vcs.DownloadFile($serverPath, $fileName)
    
    # even better: manipulate entirely in-memory
    $item = $tfs.vcs.GetItem($serverPath)  # tons of GetItem(s) overloads available
    $contents = ( [io.streamreader]$item.DownloadFile() ).ReadToEnd()
    $contents | ? { some-condition } | do-coolstuff
    

    【讨论】:

    • 您也可以使用 /output 参数来代替“tf view xx > %temp\file.text”。然后命令变为: tf view $/path/to/file.txt /version:1234 /output:"%temp%\file.txt"
    • 需要有一种方法通过 GUI 来做到这一点 - 疯狂
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-25
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多