6
votes

I get this error from SQLPackage: "An item with the same key has already been added" What is the meaning? Google won't help me..

"c:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe" /Action:DeployReport /SourceFile:"XXX.dacpac" /Profile:"publish.xml" OutputPath:"Report.xml"

Generating report for database 'XXX' on server 'srv'.

* An item with the same key has already been added.

No output file is created.

Generate script from Visual Studio works (I get a script). I have tested with three projects in the same solution. Only one creates a DeploymentReport-file.

Publish works.

2
Do you have anything in your output report? Can you try generating a script to see what the script is trying to do? Does this happen before you run anything? What version of SSDT are you using? Does this happen if you run the Publish profile through the VS IDE? - Peter Schott
Thank's. I updated the question. - SAS
I did a quick Bing search on that message and one person seems to have had success by clearing out a cache. Can't say that will help you, but you might have some success there. - Peter Schott

2 Answers

9
votes

I just ran into this issue. For anyone else who gets this, try the following.

  1. Delete the [project].dbmdl file in the root of the project folder.
  2. Close and re-open the project.
  3. Clean the solution/project.
  4. Build the DACPAC again.
  5. Publish/Script/Report the DACPAC.

I believe it is related to a cache of the dependancies becoming corrupt.

4
votes

I was having the same issue. The weird thing was I could publish from Visual Studio without a problem, but as soon as I tried to publish from the command-line using SqlPackage I got this error.

For me it turned out that there were duplicate SqlCmdVariable's in my *.publish.xml file. I removed the duplicates and now publish without a problem from the command-line.