Search code examples
iosxamarinazure-devopsprovisioning-profilebuild-agent

Duplicate key in provisioning profile causes build failure: error MSB4018


My Xamarin build tasks are failing in my Azure Dev Ops pipeline with:

error MSB4018: The "DetectSigningIdentity" task failed unexpectedly.

error MSB4018: System.ArgumentException: An item with the same key has already been added. Key: com.apple.developer.associated-domains

On opening the provisioning profile installed on the build agent I can indeed see that the com.apple.developer.associated-domains key is included in the entitlements dictionary twice:

<key>Entitlements</key>
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>xxxxxxx</string>        
    </array>
    <key>get-task-allow</key>
    <false/>
    <key>application-identifier</key>
    <string>xxxxxxxx</string>
    <key>com.apple.developer.healthkit</key>
    <true/>
    <key>com.apple.developer.healthkit.access</key>
    <array>
        <string>health-records</string>
    </array>
    <key>com.apple.developer.associated-domains</key>
    <string>*</string>
    <key>com.apple.developer.team-identifier</key>
    <string>xxxxxxxxx</string>
    <key>com.apple.developer.associated-domains</key>
    <string>*</string>

</dict>

I edited the provisioning profile on the agent and removed the duplicate and disabled the install provisioning profile task and it works. However this manual workaround doesn't work for hosted build agents.

Any ideas why this is happening or how to fix? (I redacted sensitive stuff above with xxxxxxx).


Solution

  • Having the exact same problem. This just started occurring it appears on 12/12 or 12/13. Our mobile builds are dead in the water.

    Either Xamarin will gracefully handle the duplicate now being caused by Apple or Apple resolves the regression and removes the duplicate.

    Referencing:

    https://forums.developer.apple.com/message/343811#343811

    https://forums.xamarin.com/discussion/146770/the-detectsigningidentity-task-failed-unexpectedly

    Possibly related (failure occurred at the same time as the Developer Portal update when the above problems began)

    https://github.com/fastlane/fastlane/issues/13916