Script for creating workspace and initial folder structure in TFS

Script for creating workspace and initial folder structure in TFS

October 21, 2008 | Visual Studio 2008, Visual Studio ALM

At a client site this week, and having to generate the same initial folder structure for many team projects, so I thought I would create a script (.BAT file, no PowerShell sorry).

Below is the script, but here are a few details to point out:

  • I assume that my workspace name and local folder name is the same as the team project
  • I put my local workspace folders under a common D:Workspaces folder
  • You can set the team project name easily by tweaking the SET line below
  • I could have, and should have parameterized the folder root, TFS, comments, etc.

Hope you can make use of it:

@ECHO OFF

SET TeamProject=Sample

ECHO Create folder Structure
ECHO.

D:
CD
MD D:Workspaces
MD “D:Workspaces%TeamProject%”
MD “D:Workspaces%TeamProject%Code”
MD “D:Workspaces%TeamProject%CodeDEV”
MD “D:Workspaces%TeamProject%CodeQA”
MD “D:Workspaces%TeamProject%CodePROD”
MD “D:Workspaces%TeamProject%Documents”
CD “Workspaces%TeamProject%”

ECHO.
ECHO Drop existing workspace
ECHO.

“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” workspace /delete /noprompt /server:TFSSRV1 “%TeamProject%”

ECHO.
ECHO Create workspace mapping
ECHO.

“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” workspace /new /noprompt /computer:TFSSRV1 /comment:”Created by Richard Hundhausen” /server:TFSSRV1 “%TeamProject%”
“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” workfold /server:TFSSRV1 /workspace:”%TeamProject%” /unmap $/
“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” workfold /server:TFSSRV1 /workspace:”%TeamProject%” /map $/”%TeamProject%” D:Workspaces”%TeamProject%”

ECHO.
ECHO Adding folders to version control
ECHO.

“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” add Code /recursive /noprompt
“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” add Documents /recursive /noprompt

ECHO.
ECHO Check in
ECHO.

“C:Program FilesMicrosoft Visual Studio 9.0Common7IDETF.EXE” checkin /comment:”Created by Richard Hundhausen” /noprompt /recursive “D:/Workspaces/%TeamProject%”

PAUSE