Command-line Tools

You can manipulate any part of the version control system using the Team Foundation command-line tool. The tool itself is called tf.exe (short for Team Foundation). For example, to create a new workspace, simply type the following command:

     > tf.exe workspace /new MobileExplorerProject 

In the preceding example, a new workspace is created, called MobileExplorerProject. You can exercise a great deal of control over the source control system using the tool. For example, you can manipulate workspaces and workfolders, permissions, changesets, labels, and much more.

You can also use the command-line tool to monitor how long files have been checked out. To get a report about the changes in your workspace, simply type the following:

     > tf.exe status /server:YourTFSServerName /format:detailed 

The Team Foundation version control command-line tool will enable you to perform operations that you can't perform using the Source Control Explorer. One such operation is the baseless merge (merge command). A baseless merge enables you to relate and merge two version control branches (when they aren't directly branched).

If you want to bundle several commands together, you can use a command file. A command file is a text file with the .tfc extension (similar in concept as a DOS batch file). You can insert remarks (rem) and use commands such as cd (to change directories) and exit (to escape the command file — you can also use quit).


Note that the special rem, cd, and quit commands are supported only within command files. They aren't supported in other version control operations.

Here is the source code for CheckoutCode.tfc:

     get %1     checkout %1     get %2     checkout %2     rem manipulate the code as you wish     checkin 

You can execute the command file by using the following syntax:

     > tf.exe @CheckoutCode.tfc source1.cs source2.cs 

In the preceding example, source1.cs is checked out of version control and then source2.cs is checked out. You can then add a variety of commands to manipulate the files (such as branching and merging).


Rather than completely rewrite all of the commands in this chapter, we highly recommend you refer to the MSDN documentation either online or as part of your Team System install. Buck Hodge's blog ( is also a great source for Team Foundation version control information, hints, and tips.

Professional Visual Studio 2005 Team System
Professional Visual Studio 2005 Team System (Programmer to Programmer)
ISBN: 0764584367
EAN: 2147483647
Year: N/A
Pages: 220 © 2008-2017.
If you may any questions please contact us: