Ever wanted to pull an update from the TFS server for all workspaces you have without having to start up the Visual Studio? Well I did. Visual Studio is rather slow in starting up and then you have to navigate to the TFS explorer (clicky clicky) and manually update the workspaces (clicky clicky) and then wait till the whole thing is done and VS becomes responsive again (waity waity).
You have the
tf.exe command which you can use from a command prompt, but that requires you to use the VS command line because the right paths are set there. You could set the paths so they are available in all your shells, but that’s not very handy either.
I just wanted a batch script that I could run from any shell, that would just update my workspaces for me. Nice and easy.
Like when I press CTRL-R in Windows (Run) and type
getfoo.cmd<enter>, it just makes it all happen for me.
So here’s how I did that:
@echo off cls :: Importing VS 2012 command line variables so we can run TF.exe if exist "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" ( echo Importing VS 2012 environment variables... setlocal call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" ) echo. echo *** Updating TFS workspaces *** echo. :: Repeat this for all workspaces you want to update. d: cd D:\WS\pathtosolutionfiles\ tf get . /version:T /recursive echo. echo *** Workspace updated. *** echo.
2 replies on “how to get code from tfs from the command line”
Well I haven’t used ANT myself as a build tool but I bet you can run scripts like the one I listed in my post to get your source code from TFS. Also check if there aren’t any plugins or extensions that can already do that for you. ANT has been around for a while so I bet there is something like that out there.
The tf.exe command comes with Visual Studio so you can try it out in the VS command line tool and see what other command line parameters you might need.
I am looking to get the latest version of code from TFS using ANT, How do I achieve the functionality? Any suggestions please.