Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need command to get a file from TFS without a workspace

Tags:

powershell

tfs

What I want to do is get a specific version of a file from TFS to a location other than my workspace using the command line (either tf.exe or powershell)

I want to do this so that it doesn't affect the files in my workspace, and places the file into a release folder.

tf.exe only seems to support getting a file to your workspace.

I haven't found a way to do it with Powershell either.

Can anyone help me out?

like image 710
Danny Frencham Avatar asked Jul 24 '09 05:07

Danny Frencham


1 Answers

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
like image 176
Richard Berg Avatar answered Sep 25 '22 21:09

Richard Berg