104

I use WinXP, VS 2008 and Team Explorer to connect to Team Foundation Server.

I need to script (e.g. BAT file script) the following:

  • Get latest version of folder in Team Project.
  • Check out files of folder in Team Project.
  • Check in files of folder in Team Project.

My TFSProject is $/Arquitectura/Main/, mapped to the path C:\TFS\Arquitectura

Does anyone have any sample code or suggestions?

Zoe
  • 23,712
  • 16
  • 99
  • 132
Kiquenet
  • 13,271
  • 31
  • 133
  • 232

5 Answers5

163

Use tf.exe in the command line.

In the following examples, the %PathToIde% is usually on a path like this: %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE, or on Windows x64: %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE (depending on Visual Studio version and installation settings).

Example for get:

cd C:\TFS\Arquitectura
"%PathToIde%\TF.exe" get $/Arquitectura/Main /recursive

Example for checkout:

cd C:\TFS\Arquitectura
"%PathToIde%\TF.exe" checkout $/Arquitectura/Main /recursive

Example for checkin:

cd C:\TFS\Arquitectura
"%PathToIde%\TF.exe" checkin $/Arquitectura/Main /recursive

See for more information on the tf commandline.

Stefan Steinegger
  • 60,747
  • 15
  • 122
  • 189
Ewald Hofman
  • 12,628
  • 3
  • 36
  • 44
  • 5
    "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" get $/Project /recursive for VS 2010 on Win x64. Thanks for input, very useful! – Andreas Reiff Sep 19 '12 at 16:24
  • 1
    "%VS120COMNTOOLS%..\IDE\TF.exe" get $/PROJECT_NAME /recursive for VS2013 – igorushi Apr 27 '15 at 07:16
  • Sorry for digging up this old post, but i have a question: When working with different local TFS workspaces, where do i specify the workspace to use? Or is this implied by the current working directory? – Scrontch Sep 26 '16 at 08:19
12

Update for VS2017

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe'

Mark Monforti
  • 415
  • 4
  • 5
5

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\tf.exe" get "$/ProjectName/Main" /force /recursive

Jeff Bramlett
  • 59
  • 1
  • 1
4

get up to date code for Windows 7 64bit

"%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" get /recursive

This worked for me.

Shevliaskovic
  • 1,522
  • 4
  • 23
  • 41
krish
  • 41
  • 1
0

I tried the following piece of code in Powershell on Windows 10 64-bit and it worked for me:

cd C:\MyWorkspace
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\TF.exe" get $/TFSFolderPath /recursive

Please note that the second line starts with an Ampersand (&), my code doesn't work without it, don't know the reason for it though.

Jaideep Dhumal
  • 427
  • 4
  • 5