Wednesday, November 27, 2013

TFS: Error deleting Team Project

Recently I needed to cleanup a collection, removing a number of team projects from it. Generally all went fine, but one team project refused to be deleted, saying something like that:

Error logs said not much:
Executing step: 'Delete the team project data from Version Control' VersionControl.DeleteTeamProject (2 of 11)
[Error] Violation of PRIMARY KEY constraint 'PK__#yourLoc__FEE84A3672E9B4C6'. Cannot insert duplicate key in object 'dbo.#yourLocalPendingChanges'. The duplicate key value is (51843).

What I understood from it, is that it failed to delete team project from the source control. Oh well, thought I, I can try to delete from command line. So I did and hit:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>tf destroy "$/MyProject" /collection:http:\\localhost:8080\tfs\defaultcollection
TF246021: An error occurred while processing your request.
Technical information (for administrator):
SQL Server Error: 2627

At this moment things started looking very dark. I tried of course deleting again from Admin console, and of course with no luck.

But indeed I found the solution :)

I used the destroy command to drop things under source control one by one. Like :
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>tf destroy "$/MyProject/Subfolder1" /collection:http:\\localhost:8080\tfs\defaultcollection
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>tf destroy "$/MyProject/Subfolder2" /collection:http:\\localhost:8080\tfs\defaultcollection
At first to folders I hit the same error, but I kept going and then, after some folders got successfully deleted, all others, even those wich were giving error - also got deleted. 

So when all subfolders was deleted I ran again:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>tf destroy "$/MyProject" /collection:http:\\localhost:8080\tfs\defaultcollection
And it all went good!
So, back to admin console and  delete project again - voila!

I am certain I am not the only one who hit the problem and desperately googled without any result :)
So hope this solution will work for others as well!

1 comment:

  1. Helped me out this, thanks. Same problem occurred to me, no hint as to which folder is at fault from TFS, just the usual useless error messages. What kind of VCS lets itself get into this kind of state? TFS isn't a patch on SVN or Git.