Upon one-click publish: Exception in executing publishing: An item with the same key has already been added

前端 未结 4 818
抹茶落季
抹茶落季 2021-01-21 06:03

I realize that a billion people have asked about this error, but I\'ve looked at all of them. Mine seems different. I\'m not getting any sort of source code error, no stack trac

相关标签:
4条回答
  • 2021-01-21 06:49

    While @Andrew's method is the correct approach, I find it faster to just delete the offending publish profile and reinstall / create a new one. I keep my publish profile in the same place so it takes about 10 seconds to re-install.

    0 讨论(0)
  • 2021-01-21 06:50

    I was wrong about there not being any changes to the publishing profile. Here is what happened.

    I set up a code-first Entities context called, say, MyDBContext. In my publishing profile myprofile.pubxml, Some code automatically gets inserted like this:

    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="MyDBContext" ......
    <MSDeployParameterValue Include="$(DeployParameterPrefix)MyDBContext-Web.config Connection String" />
    

    Then, I decide to try the EDMX stuff. But I save my old structure just in case. Now the File looks like this:

    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="MyDBContext" Order="1" ......
        <ObjectGroup Name="myEntities" Order="2" ......
    <MSDeployParameterValue Include="$(DeployParameterPrefix)MyDBContext-Web.config Connection String" />
    <MSDeployParameterValue Include="$(DeployParameterPrefix)myEntities-Web.config Connection String" />
    

    But then, I decide to ditch the EDMX stuff. Somehow, though, instead of removing the second set of entries in the .pubxml file, this happened:

    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="MyDBContext" Order="1" ......
        <ObjectGroup Name="MyDBContext" Order="2" ......
    <MSDeployParameterValue Include="$(DeployParameterPrefix)MyDBContext-Web.config Connection String" />
    <MSDeployParameterValue Include="$(DeployParameterPrefix)MyDBContext-Web.config Connection String" />
    

    Voila. Second set removed, and I'm good to go.

    0 讨论(0)
  • 2021-01-21 06:58

    instead of deleting, go inside properties/PublishProfiles, open the .pubxml file and check to see if your connection strings have been repeated/duplicated. I had this issue, removed all the duplicate connection strings to leave one remaining and it solved my issue.

    0 讨论(0)
  • 2021-01-21 07:00

    I got this error. It turns out there was a binding error with the solution file. Had to delete the publishing files and bind the solution. Then I could use the Publish button again.

    0 讨论(0)
提交回复
热议问题