Scripting TFS workspace creation

I’ve worked with teams that have a common way of configuring workspace and working folder mappings. Although you could save these mappings to a wiki and let people copy-and-paste them into the workspaces dialog, there is another way.

A great way to share these mappings would be to script them using the tf.exe command line tools.

Workspaces are created using the "tf workspace" command.

tf workspace /new /server:http://tfs-server:8080 MyWorkspace

Working folder mappings are created using the "tf workfold" command. It’s easiest to change to the local directory that you want to work from and run:

mkdir D:\Code\ProjectX

cd /d d:\code\ProjectX

tf workfold /server:http://tfs-server:8080 $/ProjectX