Deployment Failure: "An item with the same key has already been added"

We are receiving reports from customers that they are encountering a deployment failure of their database projects using the GDR release. This issue typically occurs when the project is copied to a new location on disk or when the solution configuration is changed with a specific sequence.  This deployment issue is caused by a bug we currently have in the product that will create duplicate references to .dbschema files.  The deployment error will look similar to:

 

The specific error that will be emitted during deployment caused by this issue is:
Error MSB4018: The "SqlDeployTask" task failed unexpectedly. System.ArgumentException: An item with the same key has already been added

 

The bug will be resolved in the upcoming GDR service release. Until then, you can work around this issue using the following steps below.

 

Use these steps when referencing a .dbschema file:
1. Close or unload project.
2. Edit project file and update the include and hint path to use the same relative path.
3. Delete .dbmdl file in the root of the project folder.
4. Open or reload project.
5. Clean project/solution or delete files in output and obj directories.
6. Build and Deploy.

 

Use these steps when referencing a Server Project:
1. Close or unload project.
2. Delete .dbmdl file (for each project).
3. Open or reload project.
4. Clean project/solution or delete files in output and obj directories.
5. Build and Deploy

Comments

  • Anonymous
    March 05, 2009
    PingBack from http://www.clickandsolve.com/?p=18529
  • Anonymous
    June 23, 2009
    I've been looking around for this fix.  Most other articles omit step 5 (delete files in output), which must make all the difference.Any idea when a fix will be posted for this?
  • Anonymous
    June 23, 2009
    The comment has been removed
  • Anonymous
    August 15, 2011
    The comment has been removed