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 kevin at 1:57 PM in Net

 

Comment: James Manning at Sun, 1 Jul 9:44 AM

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 :)

Comment: Kevin Jones at Sun, 1 Jul 9:44 AM

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

Comment: Michael at Mon, 22 Oct 5:33 PM

I have a related issue, we had several "Test" projects we created in TFS, we added items to source control, make changes, etc... We then "deleted" the projects via the TFSDeleteProject command which indicated that the projects were deleted successfully.

The issues are these:
1) when i go to "View Pending Changes" the files that were changed for the test projects still show up even though we deleted these projects from TFS AND I deleted the physical files from my machine. Of course if I attempt to "check in" an error is thrown saying that the files no longer exist.

2) all of the deleted projects still show in the Source Control Explorer but do not show in the Team Explorer window. To clarify what I mean if you open the Team Explorer tab and select "Add Existing Team Project" these deleted projects do not show, but if you expand an existing project (any project, doesn't matter which one) in Team Explorer, then double click on the "Source Control" item under this project you are taken to the Source Control Explorer area where all the projects are shown, even the deleted ones (which makes zero sense). I looked in SQL Server under the TfsIntegration database at tbl_projects to see if these are stored there, which they are not.

Thinking this was a local machine issue I grabbed my laptop and connected to Source Control Explorer only to see the exact same thing, proving that this issue is with data on the server and not on my local machines.

I also received a "TFS Error: Paramater Value cannot be null: Key" when I would attempt to check in anything for any project. I downloaded VS 2008, installed Team Explorer 2, checked in the work i needed to get into TFS and this seems to have resolved the issue with the TFS Error (at least for now).

So I need help with two things: I need to get these test projects truely and completely removed from the system, I also need to get rid of the "Pending changes" for these projects. I tried deleting the entire Team Foundation cache on my machine but this did not solve the problem.

Any help you can provide is much appreciated.

Your comment:

SCode: (*) Generate another code
SCode

Please enter the code as seen in the image above to post your comment.

(not displayed)
 
 
 

Live Comment Preview:

 
« November »
SunMonTueWedThuFriSat
  12345
6789101112
13141516171819
20212223242526
27282930