Since the release of the March
2008 TFS Power tools, it is possible to write scripts to automate the creation
of new Team Projects. So this is a little walk through on how to use this feature.
Two important remarks:
-
You need to have Visual Studio 2008 Service Pack 1 installed. But as there's
no Service Pack 1 for the moment, you could use the beta of it. Download it here.
-
If you have, like me a test VPC with and the server and the client, you need first
install the Visual Studio 2008 Service Pack 1 and then also the Team Foundation Server
Service Pack 1. You can download the TFS SP1 here.
The command you have to use is this : tfpt createteamproject /validate /server:tfsservername
[/teamproject:teamprojectname] [sourcecontrol:Branch:[branchpath]] [/processtemplate:[templatename]]
or you could use a settingsfile and the command would look like this tfpt createteamproject
/validate /settingsfile:filespec. Using the settingsfile is a lot easier.
A bit about the parameters :
|
/validate |
Validate all the settings, no project will be created. If you leave this from
the command, your project will be created. |
|
/verbose |
Specifies that team project creation log information is to be printed to the console.
|
|
/log |
Specifies that team project creation log is to be written to a specific folder |
|
logfilespec |
Specifies the folder where the team project creation log file is to be stored. |
|
/server
|
Specifies that a TFS server is used |
|
tfsservername |
Specifies the name of the TFS server |
|
/teamproject |
Specifies the Team Project name |
|
teamprojectname |
Specifies that the source control is used |
|
/sourcecontrol
|
Specifies the name of the team project
|
|
New |
Specifies that the source control of the team project creates a new path |
|
None
|
Specifies that the source control is not enabled when creating the team project. |
|
Branch |
Specifies that the source control of the team project branches from an existing path |
|
/processtemplate
|
Specifies that a process template name is used. |
|
templatename
|
Specifies the name of the process template. |
|
/settingsfile |
Specifies that a team project creation file is used |
|
filespec |
Specifies the file containing team project creation settings |
OK, let's make a little example now. The example I will show make use
of a setting file. Let's start with the XML. This XML file contains all our
settings for our project.
1: <?xml version="1.0" encoding="utf-8"?>
2: <Project xmlns="ProjectCreationSettingsFileSchema.xsd">
3:
4: <TFSName>win2k3</TFSName>
5:
6: <LogFolder>
7: c:\RemoteTFSProjectStart
8: </LogFolder>
9:
10: <ProjectName>
11: My
First Auto project
12: </ProjectName>
13: <ProjectSiteTitle>
14: <!--
default to project name if not specified -->
15: My
First Auto project
16: </ProjectSiteTitle>
17: <ProjectSiteDescription>
18: <!--
default to empty string if not specified -->
19: This
is my first attemp to automaticly create Team Projects
20: </ProjectSiteDescription>
21: <SccCreateType>
22: <!--
none | new | branch -->
23: New
24: </SccCreateType>
25: <SccBranchFromPath>
26: <!--
string.Empty for none and new; supplied for branch -->
27: string.empty
28: </SccBranchFromPath>
29: <ProcessTemplateName>
30: MSF
for Agile Software Development - v4.2
31: </ProcessTemplateName>
32: </Project>
So this is pretty easy. Next step is to run the createteamproject command :
-
Start the command prompt
-
Go to C:\Program Files\Microsoft Team Foundation Server 2008 Power Tools
-
Usage: tfpt createteamproject /settingsfile:<path to >AutoCreate1.xml (be sure
that you put the path to the settingsfile with it)
-
If alle settings are correct your team project will be created.
Three things are missing:
-
Area's
-
If necessary creating of new TFS security groups
-
Adding your users to the correct groups
But all three items can also be in the automated process by calling a service afterwards.
This service will can the TFS API's to do these jobs.
Why would you use this?
Well in our company we are busy with creating an Infopath form, where project leaders
can request a new team project. After they submit the form, one of the three
TFS administrators approve this request and then a workflow will start to automatically
create the team project and put the security correct.
Click here to see the original post