Monday, 28 November 2005
Removing TFS Zombie Projects
Today I was testing the Team Foundation Server part of VSTS. I was adding and removing projects to get the screenshots for the course I'm in the process of authoring. At some point I added a project then deleted it using TFSDeleteProject (TFSDeleteProject ships with Visual Studio 2005 Team Explorer, it's in the c:\program files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\ directory).
Having deleted the project I tried to re-add it. The wizard started to run the add task and failed towards the end telling me that it could not rollback the addition. This is an omimous message as it means you have a "zombie" project. You can't remove the project from TFS and you can't list the project in the team explorer.
Taking my courage in my hands I looked at the SQLServer 2005 TFS tables (there are dozens of them), for a clue as to what is going on. If found a couple of things. In the TfsIntegration databse there is a table called tbl_projects and this has a column called 'state'. For projects that had been correctly installed the value of this was 'WellFormed' for my zombie project it was 'New' (IIRC, I've sinced chenged the value and my memory isn't what it used to be). Changing this value to 'WellFormed' for my zombie project lets me add the project to the Team Explorer but I still couldn't delete it using TFSDeleteProject.
My next thought was to run the SQL Server profiler to see what TFSDeleteProject was sending to the database to delete the project. It appears that TFSDeleteProject first checks that this user has permissions to delete the project. It then calls this "exec ObjectExists @Path=N'/Foobar',@AuthType=1" on SQL Server's Report Server, i.e. does the Report Server have an entry for the project. It turned out in my case that Report Server did not have an entry. It looks like the Add Project Wizard failed before adding the reports to the Report Server.
Opening Report Server in SQL Server Management Studio and adding a new Folder called 'FooBar' (the name of the project) fixed the problem. Now, running TFSDeleteProject deleted the project. I had to run TFSDelete /force to make sure that TFSDelete continues even if it finds errors. I no longer have a zombie project.
I've also seen zombie projects when TFS seems not to be correctly installed, not sure if this has the same root cause but hopefully this post will save people some wasted time.
* Edited * Thanks to James Manning for pointing out that the that name of the exe used to delete projects is TFSDeleteProject and not TFSDelete which I had used originally
Posted by at 1:57 PM in Net
Hey James,
I did post this on the forums but I found the answer before you guys had woken up! (I'm in th UK).
I had seen your sample (listing the projects) but I was trying to run it on a machine that;s not in the domain and is not authenticated so I need to amend it to accept credentials. Now if only I can find the latest documentation for the TeamFoundation APIs

Good job!
This has come up on the Team Foundation forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=22&SiteID=1) a good bit. You're the first I've heard of to figure out to create the folder on their own.
Couple of minor notes:
- the utility is called TfsDeleteProject.exe (just noting in case someone runs across this post and tries to find a TfsDelete.exe)
- the bug where TfsDeleteProject needs the reporting folder to exist has been fixed post-beta3 (as have many other bugs in TfsDeleteProject)
- when parts of the project (like the folder on the Reports Server) are just missing (not broken), you won't need to use /force post-beta3
- To list the projects on a Team Foundation server, both those WellFormed and those not, you can use the little ListTeamProjects sample I posted @ http://blogs.msdn.com/jmanning/archive/2005/10/14/481105.aspx (zip available @ http://manningj.members.winisp.net/examples/ListTeamProjects.zip)
- as you've probably guessed, projects are created in the New state at the very beginning of the project creation wizard running to create the project) and only transitioned to WellFormed after all the parts have been successfully created. The parts involved are fully customizable (and extensible) via the process methodology template. You can download the existing templates or upload new ones via the Project Template Manager.
Congrats again on figuring it out on your own, but we're also available on the forums to help out, too :)