Scripting Team Project Creation in TFS2010

In TFS2008 SP1 and the subsequent power tools release it was possible to create a team project from the command line. You can read Will-Peter’s detailed blog post on Creating a Team Project from the command line in TFS2008.

In TFS2010, it’s still not as good as we would like (it’s still client-based rather than server-based). But there’s one important difference – the feature has been rolled into the product and is no longer a power tool.

How to create a team project from the command line in TFS2010:

Create an XML file with the following contents and save it somewhere (e.g. C:\temp\pcw.xml). Substitute the highlighted as appropriate:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="ProjectCreationSettingsFileSchema.xsd">
       <TFSName>http://tfsserver:8080/tfs/DefaultCollection</TFSName>
       <LogFolder>c:\temp</LogFolder>
       <ProjectName>TestAgile2</ProjectName>
       <ProjectSiteEnabled>true</ProjectSiteEnabled>
       <ProjectSiteTitle>TestAgile2</ProjectSiteTitle>                 
       <ProjectSiteDescription>TestAgile2 project created from command line</ProjectSiteDescription>
       <SccCreateType>New</SccCreateType>
       <SccBranchFromPath></SccBranchFromPath>                
       <ProcessTemplateName>MSF for Agile Software Development v5.0</ProcessTemplateName>
</Project>

Once you have created the file, you need to prepare Visual Studio to be automated and trigger the automation from the command line.

  1. Open Visual Studio 2010
  2. Go to View > Team Explorer and make sure that the Team Explorer tab is active
  3. Close Visual Studio 2010
  4. Open a command prompt
  5. Type: CD /D %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE
  6. Type: devenv /command "File.BatchNewTeamProject C:\temp\pcw.xml"

At this point, Visual Studio will open and the Team Explorer tab will show “Connecting to server\collection…”.  In the background it’s actually creating the team project. You can verify this by looking for a txt file with the name of your project in the path you specified for LogFolder. (e.g. c:\temp\TestAgile2.txt)

Team Explorer connecting to server

Once the project has been created, you can select ‘Add existing team project’ and select it from the dialog.

Connect to Team Project dialog

If you want to create a fully-automated project provisioning system there are a few other things that you’ll need to do on top of creating the team project. Some of these things are:

  • Add users to TFS groups (Project Administrators, Contributors, Readers)
  • Add permissions in sharepoint
  • Add permissions in reporting services
Published 25 September 09 02:17 by grantholliday

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Mattias said on October 7, 2009 3:36 PM:

A step in the right direction, I think. I would of cource prefer to have this capability included in the tfs api. Im just getting nervous the GUI part will limit the possibility to write a fully automated  project provissioning system, as it will require interaction wit the desktop.

I have written some kind of a automated project provissioning system for TFS2008, with extensions to the TSF Warehouse. I have some post on the subject and the source at at http://mskold.blogspot.com/2009/08/team-system-administration-in_12.html

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker