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"?>
<ProjectSiteDescription>TestAgile2 project created from command line</ProjectSiteDescription>
<ProcessTemplateName>MSF for Agile Software Development v5.0</ProcessTemplateName>
Once you have created the file, you need to prepare Visual Studio to be automated and trigger the automation from the command line.
- Open Visual Studio 2010
- Go to View > Team Explorer and make sure that the Team Explorer tab is active
- Close Visual Studio 2010
- Open a command prompt
- Type: CD /D %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE
- 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)
Once the project has been created, you can select ‘Add existing team project’ and select it from the 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