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.
Firstly, are you wanting a copy of the controlled files that are no longer under source-control (such as a SVN export) or are you still hoping to work with the files and TFS?
Option 1: No Binding at all
If you simply want a copy of the latest files and no ‘binding’ to TFS, you’re going to have to do a little work yourself. Leaving aside credentials (
[/login:username,[password]]parameter to many command line methods).TFcommand to get a list of the files:tf dir "$/YourSolution" /Recursive > files.txtfiles.txtwith some clever batch file (or use a scripting language):$/and this is the directory, create the directory in your destination (remove first three characters and the last character, a colon).%file%and directory%dir%, then issue the following command (for each file in that directory):tf view "$/%DIR%/%FILE%" "/output:Your-Target-Path/%DIR%/%FILE%"or if you’re happy with the current directory as the target:
tf view "$/%DIR%/%FILE%" "/output:%DIR%/%FILE%"Note, you need the
%DIR%/%FILE%in the output part or all files will be dumped in to the same directory.NOTE: this is likely to a be VERY high bandwidth and slow operation!
Option 2: Temporary Mapping
tf workspace /new /collection:<URL_TO_SERVER> /permission:Private(note, this will prompt, there is a no-prompt option but determining a name for the workspace is left as an exercise)LOCALDIRtf workfold /map "$/SERVER_DIR" "LOCALDIR"LOCALDIRtf get . /RecursiveAt this point you should now have all of the files and if you wanted you also have a binding with TFS so you could commit changes. Alternatively, you can now copy the content elsewhere and break the mapping/workspace. Using the correct command line variants of
tf workfold /unmapandtf workspace /deletewill unmap your workfolder and delete the workspace.