TFPT – “An item with the same key has already been added.”

Mar 12, 2016 ALM, General
[Reading Time: 3 minutes]

This day I struggled into an issue with migrating a shelveset from one branch to another. Unfortunately, an error appeared, so I got stuck.

To migrate my shelveset, I use tfpt.exe, that comes with Microsoft Teamfoundation Powertools 2015. So, I first started with typing following command into a developer command prompt:
tfpt unshelve migrate /source:”$/RootProject/SubProject/Branch1” /target:”$/RootProject/SubProject/Branche2” “shelvesetName”

Hint: To get this working, make sure you are calling tfpt.exe from the path, that is the root of you mapped path under beneath. In my case, I would go by “cd” to c:\Projects\RootProject\SubProject\Branch1

Now a dialog appears, that displays all shelveset details.image

From here you can go migrating this by clicking “Unshelve”. The next Dialog, that should appear, should display a bunch of unresolved conflicts, if any. These, you can either merge automatically ore by hand – it’s up to you. In my case nothing happened and console brought up an error – instead of the second dialog, saying “An item with the same key has already been added”. The content of this message is not really descriptive and meaningful… so what is the cause?

First I tried to figure out, where the root cause of this message was, but (honestly) then I felt more and more lazy, doing deep dive, so I considered looking up hints by the use of a Search engine Winking smile.

Here I found several solutions, ranging from adventure, over useless to senseless. But in general – luckily – there were recommendations for undoing pending changes in source (and often also for undoing these in target branch).

I tried some of these hints, but nothing worked. So I played a little bit around and found, that I was that far from a solution with undoing pending changes. It was not only undoing for source and target branch, but it was undoing everything in my Workspace to get that error message away and letting tfpt.exe work as expected.

As a conclusion, be sure, that you first make a “backup” of all pending changes in your workspace, by sending these to a temporary shelveset. Than you can undo all changes and migrate you desired shelveset to the target branche, that you chose before. After successful migration/move, you can restore the “Backup”-shelveset to your workspace. There you are…you moved a shelveset.

By root

As a Managing Consultant, I am working at Alegri in Stuttgart/Germany. There I keep focusing with a team specialized in IoT, UX/Design and DevOps on preparing customers for the next digital future. I have been working as IT Consultant, IT Architect and lead developer with skills in .NetFramework, agile methodologies like Scrum and much more for nearly 2 decades. In the last few years I started focusing in IoT & Digitalization strategies in enterprise scenarios. Manly I used Microsofts Azure Cloud, to support customers in letting their visions become true. Sharing knowledge and practicing principles is something, that I like very much. Therefore I am also Co-Administrator of Azure-Meetup group in Stuttgart, where I'd also like to share my experiences. With this I was awarded in november by Microsoft as a MVP (Most Valuable Professional).

4 thoughts on “TFPT – “An item with the same key has already been added.””
  1. This was the perfect solution when trying to unshelve into a different branch. I had files checked out in other solutions in the Workspace. Once shelved or checked in it worked like a charm. Thank you so much.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.