Friday, May 1, 2009

How to delete Team Project on TFS 2008

I have experienced some issue while deleting Team Projects.

Because we had too many obsolete projects on our Team Foundation Server, we decided to delete them. First I backed up the whole database. For the detailed instruction, read Microsoft’s paper: How to: Back Up a Team Foundation Server

To delete a Team Project, you have to use the TFSDeleteProject command from the Visual Studio 2008 Command Prompt. This operation cannot be done from the Team Explorer.

Preparation

Before doing this operation we have to clarify what will be the state of the branched code. I have found the answer on the following Microsoft site: Using TFSDeleteProject to Delete Projects on Team Foundation Server. The FAQ section’s first question clarifies this issue: only those source control items will be deleted whose in the deleted Team Project. The deletion not will operate outside of the given Team Project. I tried it, and it really works in this way. Note if you delete the parent of branch it will be orphaned. The work items (bugs, and more) will be deleted too.

The TFSDeleteProject command cannot be executed without all required security permission.

You have to be in the Team Project’s Administrators. To set it go to Team Explorer in Visual Studio. Right click on the team project, and select Team Project Settings > Group Membership…

image

Select the Project Administrators group, and press Properties button.

image

Add your user to the list.

You must be the SharePoint site’s Administrator.

Go to the SharePoint Central Administration Site.

image

Select the Application tab and then the Site collections administrators.

image

Select the Site Collection associated with the given Team Project and set the Primary site collection administrator to your user.

The execution

After the preparation you can issue the following command:

> TFDeleteProject /server:YOURSERVER TEMPPROJECT

The command asks for your confirmation:

Warning: Deleting a team project is an irrecoverable operation. All version control, work item tracking and Team Foundation build data will be destroyed from the system. The only way to recover this data is by restoring a stored backup of the databases. Are you sure you want to delete the team project and all of its data (Y/N)?y

If everything went good you will see the following:

Deleting from Build ...
Done
Deleting from Work Item Tracking ...
Done
Deleting from Version Control ...
Done
Deleting Report Server files ...
Done
Deleting SharePoint site ...
Done
Deleting from Team Foundation Core ...
Done

After the deletion the Team Project disappears immediately, but the Version Control items will be only flagged as they can be deleted. The Team Foundation Server will delete these items at next midnight. You can hurry this by executing the job manually. You can read here how to do this: http://msdn.microsoft.com/en-us/library/dd206696.aspx#jobhistory