Command line "get latest" from TFS without mapping workspaces and such

Viewed 23794

I assume that this:

tf.exe get $/project /recursive

...needs this weird workspace mapping, known TFS server and such.

Is there any way I could do this simplest thing: go connect to this TFS server using this set of credentials, get latest source code for this project and put it here? All from the command line.

6 Answers

i wrote the powershell for the leading answer

$base = "f:\whereyouwantthefilestogo\"
foreach($l in get-content D:\outputfromTFdir.txt)
{
    if($l -match '^\$.*\:$')
    {
        $repopath = $l.trim(':')
        write-host 'base path'
        $basepath = "$base$($l.Substring(2,$l.Length -3) -replace '/','\')"
        if((Test-Path $basepath) -eq $false)
        {
            write-host 'making directory'
            New-Item -ItemType directory -Path $basepath
        }
        continue;
    }
    elseif($l -match '^\$')
    {
        write-host 'sub folder'
        $subfolderpath = "$basepath\$($l.trim('$'))"
        if((Test-Path $subfolderpath) -eq $false)
        {
            write-host 'making directory'
            New-Item -ItemType directory -Path $subfolderpath
        }
        continue;
    }
    elseif($l -match '.*\..*')
    {
        write-host 'get file'
        $filename = "$basepath\$l"
        write-host $filename
        $repofile = "$repopath/$l"
        tf view "$repofile" "/output:$filename" /collection:http://tfsserver
    }
    else{write-host 'blank line'}
}
Related