Thursday 7 February 2019

TFS 2012 Unshelve to different branch -> An item with the same key has already been added




 need help resolving the following issue:
I am attempting to unshelve code from the source branch onto a target branch.
I am using the following:
  • VS2012 RC
  • TFS 2012
  • VS2012 x64 Cross Tools Command Prompt
When I use the command prompt to perform the unshelve operation, the following occurs:
  1. Shelveset details dialog gets displayed with list of change files.
  2. Click Unshelve button.
  3. Observe command prompt output: "An item with the same key has already been added."
I have downloaded ServicePack1 for power tools. However, I have failed to resolve this issue.


Worked::: !!!!
Try to delete all the files in the following folder and restart VS2012 (Source):
C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache

Thursday 30 August 2018


Want to move a shelveset to a different branch? It’s more painful than I realized, but not to worry, here’s exactly what you need to do.

Step 1: Preparation

Make sure your source branch and target branch are both up to date by running Get Latest Changes. If you don’t you may receive the error:
“Unable to determine the workspace.”
Make sure you’ve created your shelveset and there are no pending changes for either branch. This includes the changes you just shelved! If you don’t you may receive the error:
“An item with the same key has already been added”

Step 2: Open Command Prompt

Open up a visual studio command prompt. I used “VS2013 x64 Cross Tools Command Prompt”, very inconveniently located in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts.
Make sure you navigate to the root of (or anywhere inside) your project, or you might see this friendly guy again: “Unable to determine the workspace.”


Figure: Command prompt open and navigated to project

Step 3: Run this Command

Now run the following Command: tfpt unshelve /migrate /source:"$/ProjectName/Branch" /target:"$/ProjectName/Targetbranch" "My Shelveset Name"

Figure: Running the command using my project’s values
If you need to unshelve someone else shelveset you need to specify UserName proceeded by ";".  See below:
tfpt unshelve /migrate /source:"$/ProjectName/Branch" /target:"$/ProjectName/Targetbranch" "My Shelveset Name;UserName"
where User_Name is e.g. xxxxx

Step 4: Follow the Prompts

Now that you’ve run the command, a couple of prompts will appear. They should be quite straight forward.

Figure: The first prompt. I just clicked “Unshelv”.

Figure: The second prompt. Here I clicked “Auto-merg” and then once completed, “Close”.
After you’ve closed the final prompt, your original command window should look something like this:

Figure: You’re all done. Close this when you’re ready.
That’s it. You should see the changes from your shelveset now applied to the target branch, ready to be checked in.