title: "The "SqlBuildTask" task failed unexpectedly..." exception in SSDT
body: <p>In our VStudio 2015 solution we have a series of SSDT's. One of them is returning the exception <strong>"The "SqlBuildTask" task failed unexpectedly. Microsoft.Data.Tools.Schema.Sql.Build.BuildFailedException: An entry with the same key already exists."</strong>. I went into the Microsoft.Data.Tools.Schema.SqlTasks.targets and took a look at the  (posting it below)</p>
  
  <pre><code>&lt;SqlBuildTask   PostdeployItem="@(PostDeploy-&gt;'%(FullPath)')"
        PredeployItem="@(PreDeploy-&gt;'%(FullPath)')"
        RefactorLog="@(RefactorLog-&gt;'%(FullPath)')"
        SqlTarget="@(SqlTarget)"
  
        ContributorArguments="$(ContributorArguments)"
  
        BuildExtensionConfiguration="@(BuildExtensionConfiguration)"
        BuildContributors="$(BuildContributors)"
        DeploymentExtensionConfiguration="@(DeploymentExtensionConfiguration)"
        DeploymentContributors="$(DeploymentContributors)"
  
        ConnectionString="$(TargetConnectionString)"
        CreateScriptFileName="$(CreateScriptFileName)"
        DacApplicationName="$(DacApplicationName)"
        DacDescription="$(DacDescription)"
        DacFile="@(DacFile)"
        DacVersion="$(DacVersion)"
        DatabaseName="$(TargetDatabase)"
        DatabaseSchemaProviderName="$(DSP)"
        DefaultSchema="$(DefaultSchema)"
        DeploymentScriptName="$(DeployScriptFileName)"
        DeployToDatabase="$(UpdateDatabase)"
        GenerateCreateScript="$(GenerateCreateScript)"
        GenerateDac="$(GenerateDac)"
        ImplicitDllAssemblyName="$(AssemblyName)"
        ImplicitDllAssemblyOwner="$(AssemblyOwner)"
        ImplicitDllFileName="$(IntermediateTargetFullFileName)"
        ImplicitDllSymbolsFileName="$(IntermediateSymbolsFullFileName)"
        ImplicitDllGenerateSqlClrDdl="$(GenerateSqlClrDdl)"
        ImplicitDllIsVisible="$(IsVisible)"
        ImplicitDllPermissionSet="$(PermissionSet)"
        IntermediateDirectory="$(GeneratedFilesIntermediatePath)"
        ModelCollation="$(ModelCollation)"
        OutputDirectory="$(TargetDir)"
        PreserveHeaderComments="$(PreserveHeaderComments)"
        Source="@(Build-&gt;'%(FullPath)')"
        SqlCmdVariables="@(SqlCmdVariables)"
        SqlReferencePath="@(SqlReferencePath)"
        SuppressTSqlWarnings="$(SuppressTSqlWarnings)"
        TreatTSqlWarningsAsErrors="$(TreatTSqlWarningsAsErrors)"
        ValidateCasingOnIdentifiers="$(ValidateCasingOnIdentifiers)"
        CmdLineInMemoryStorage="$(CmdLineInMemoryStorage)"
        DefaultCollation="$(DefaultCollation)"
        AnsiNullDefault="$(AnsiNullDefault)"
        AnsiNulls="$(AnsiNulls)"
        AnsiPadding="$(AnsiPadding)"
        AnsiWarnings="$(AnsiWarnings)"
        ArithAbort="$(ArithAbort)"
        ConcatNullYieldsNull="$(ConcatNullYieldsNull)"
        QuotedIdentifier="$(QuotedIdentifier)"
        NumericRoundAbort="$(NumericRoundAbort)"
        RecursiveTriggersEnabled="$(RecursiveTriggersEnabled)"
        DatabaseChaining="$(DatabaseChaining)"
        DatabaseState="$(DatabaseState)"
        UpdateOptions="$(UpdateOptions)"
        CloseCursorOnCommitEnabled="$(CloseCursorOnCommitEnabled)"
        DefaultCursor="$(DefaultCursor)"
        AutoClose="$(AutoClose)"
        AutoCreateStatistics="$(AutoCreateStatistics)"
        AutoShrink="$(AutoShrink)"
        AutoUpdateStatistics="$(AutoUpdateStatistics)"
        TornPageDetection="$(TornPageDetection)"
        DatabaseAccess="$(DatabaseAccess)"
        Recovery="$(Recovery)"
        EnableFullTextSearch="$(EnableFullTextSearch)"
        DefaultFilegroup="$(DefaultFilegroup)"
        Trustworthy="$(Trustworthy)"
        AutoUpdateStatisticsAsynchronously="$(AutoUpdateStatisticsAsynchronously)"
        PageVerify="$(PageVerify)"
        ServiceBrokerOption="$(ServiceBrokerOption)"
        DateCorrelationOptimizationOn="$(DateCorrelationOptimizationOn)"
        Parameterization="$(Parameterization)"
        AllowSnapshotIsolation="$(AllowSnapshotIsolation)"
        ReadCommittedSnapshot="$(ReadCommittedSnapshot)"
        VardecimalStorageFormatOn="$(VardecimalStorageFormatOn)"
        SupplementalLoggingOn="$(SupplementalLoggingOn)"
        CompatibilityMode="$(CompatibilityMode)"
        DefaultFileStreamFilegroup="$(DefaultFileStreamFilegroup)"
        IsChangeTrackingOn="$(IsChangeTrackingOn)"
        IsChangeTrackingAutoCleanupOn="$(IsChangeTrackingAutoCleanupOn)"
        ChangeTrackingRetentionPeriod="$(ChangeTrackingRetentionPeriod)"
        ChangeTrackingRetentionUnit="$(ChangeTrackingRetentionUnit)"
        IsEncryptionOn="$(IsEncryptionOn)"
        IsBrokerPriorityHonored="$(IsBrokerPriorityHonored)"
        Containment="$(Containment)"
        DatabaseDefaultLanguage="$(DatabaseDefaultLanguage)"
        DatabaseDefaultFulltextLanguage="$(DatabaseDefaultFulltextLanguage)"
        IsNestedTriggersOn="$(IsNestedTriggersOn)"
        IsTransformNoiseWordsOn="$(IsTransformNoiseWordsOn)"
        TwoDigitYearCutoff="$(TwoDigitYearCutoff)"
        NonTransactedFileStreamAccess="$(NonTransactedFileStreamAccess)"
        FileStreamDirectoryName="$(FileStreamDirectoryName)"
        TargetRecoveryTimePeriod="$(TargetRecoveryTimePeriod)"
        TargetRecoveryTimeUnit="$(TargetRecoveryTimeUnit)"
        DelayedDurability="$(DelayedDurability)"
        AutoCreateStatisticsIncremental="$(AutoCreateStatisticsIncremental)"
        MemoryOptimizedElevateToSnapshot="$(MemoryOptimizedElevateToSnapshot)"
        QueryStoreCaptureMode="$(QueryStoreCaptureMode)"
        QueryStoreDesiredState="$(QueryStoreDesiredState)"
        QueryStoreFlushInterval="$(QueryStoreFlushInterval)"
        QueryStoreStatsInterval="$(QueryStoreStatsInterval)"
        QueryStoreMaxPlansPerQuery="$(QueryStoreMaxPlansPerQuery)"
        QueryStoreStaleQueryThreshold="$(QueryStoreStaleQueryThreshold)"
        QueryStoreMaxStorageSize="$(QueryStoreMaxStorageSize)"
        DbScopedConfigLegacyCardinalityEstimation="$(DbScopedConfigLegacyCardinalityEstimation)"
        DbScopedConfigLegacyCardinalityEstimationSecondary="$(DbScopedConfigLegacyCardinalityEstimationSecondary)"
        DbScopedConfigMaxDOP="$(DbScopedConfigMaxDOP)"
        DbScopedConfigMaxDOPSecondary="$(DbScopedConfigMaxDOPSecondary)"
        DbScopedConfigParameterSniffing="$(DbScopedConfigParameterSniffing)"
        DbScopedConfigParameterSniffingSecondary="$(DbScopedConfigParameterSniffingSecondary)"
        DbScopedConfigOptimizerHotfixes="$(DbScopedConfigOptimizerHotfixes)"
        DbScopedConfigOptimizerHotfixesSecondary="$(DbScopedConfigOptimizerHotfixesSecondary)"
        TemporalHistoryRetentionEnabled="$(TemporalHistoryRetentionEnabled)"
        AdditionalDeploymentContributorArguments="$(AdditionalDeploymentContributorArguments)"
        AdditionalDeploymentContributors="$(AdditionalDeploymentContributors)"
        AllowDropBlockingAssemblies="$(AllowDropBlockingAssemblies)"
        AllowIncompatiblePlatform="$(AllowIncompatiblePlatform)"
        AllowUnsafeRowLevelSecurityDataMovement="$(AllowUnsafeRowLevelSecurityDataMovement)"
        BackupDatabaseBeforeChanges="$(BackupDatabaseBeforeChanges)"
        BlockOnPossibleDataLoss="$(BlockOnPossibleDataLoss)"
        BlockWhenDriftDetected="$(BlockWhenDriftDetected)"
        CommentOutSetVarDeclarations="$(CommentOutSetVarDeclarations)"
        CompareUsingTargetCollation="$(CompareUsingTargetCollation)"
        CreateNewDatabase="$(CreateNewDatabase)"
        DeployDatabaseInSingleUserMode="$(DeployDatabaseInSingleUserMode)"
        DisableAndReenableDdlTriggers="$(DisableAndReenableDdlTriggers)"
        DoNotAlterChangeDataCaptureObjects="$(DoNotAlterChangeDataCaptureObjects)"
        DoNotAlterReplicatedObjects="$(DoNotAlterReplicatedObjects)"
        DoNotDropAggregates="$(DoNotDropAggregates)"
        DoNotDropApplicationRoles="$(DoNotDropApplicationRoles)"
        DoNotDropAssemblies="$(DoNotDropAssemblies)"
        DoNotDropAsymmetricKeys="$(DoNotDropAsymmetricKeys)"
        DoNotDropAudits="$(DoNotDropAudits)"
        DoNotDropBrokerPriorities="$(DoNotDropBrokerPriorities)"
        DoNotDropCertificates="$(DoNotDropCertificates)"
        DoNotDropClrUserDefinedTypes="$(DoNotDropClrUserDefinedTypes)"
        DoNotDropColumnEncryptionKeys="$(DoNotDropColumnEncryptionKeys)"
        DoNotDropColumnMasterKeys="$(DoNotDropColumnMasterKeys)"
        DoNotDropContracts="$(DoNotDropContracts)"
        DoNotDropCredentials="$(DoNotDropCredentials)"
        DoNotDropCryptographicProviders="$(DoNotDropCryptographicProviders)"
        DoNotDropDatabaseAuditSpecifications="$(DoNotDropDatabaseAuditSpecifications)"
        DoNotDropDatabaseRoles="$(DoNotDropDatabaseRoles)"
        DoNotDropDatabaseScopedCredentials="$(DoNotDropDatabaseScopedCredentials)"
        DoNotDropDatabaseTriggers="$(DoNotDropDatabaseTriggers)"
        DoNotDropDefaults="$(DoNotDropDefaults)"
        DoNotDropEndpoints="$(DoNotDropEndpoints)"
        DoNotDropErrorMessages="$(DoNotDropErrorMessages)"
        DoNotDropEventNotifications="$(DoNotDropEventNotifications)"
        DoNotDropEventSessions="$(DoNotDropEventSessions)"
        DoNotDropExtendedProperties="$(DoNotDropExtendedProperties)"
        DoNotDropExternalDataSources="$(DoNotDropExternalDataSources)"
        DoNotDropExternalFileFormats="$(DoNotDropExternalFileFormats)"
        DoNotDropExternalTables="$(DoNotDropExternalTables)"
        DoNotDropFilegroups="$(DoNotDropFilegroups)"
        DoNotDropFileTables="$(DoNotDropFileTables)"
        DoNotDropFullTextCatalogs="$(DoNotDropFullTextCatalogs)"
        DoNotDropFullTextStoplists="$(DoNotDropFullTextStoplists)"
        DoNotDropLinkedServerLogins="$(DoNotDropLinkedServerLogins)"
        DoNotDropLinkedServers="$(DoNotDropLinkedServers)"
        DoNotDropLogins="$(DoNotDropLogins)"
        DoNotDropMessageTypes="$(DoNotDropMessageTypes)"
        DoNotDropPartitionFunctions="$(DoNotDropPartitionFunctions)"
        DoNotDropPartitionSchemes="$(DoNotDropPartitionSchemes)"
        DoNotDropPermissions="$(DoNotDropPermissions)"
        DoNotDropQueues="$(DoNotDropQueues)"
        DoNotDropRemoteServiceBindings="$(DoNotDropRemoteServiceBindings)"
        DoNotDropRoleMembership="$(DoNotDropRoleMembership)"
        DoNotDropRoutes="$(DoNotDropRoutes)"
        DoNotDropRules="$(DoNotDropRules)"
        DoNotDropScalarValuedFunctions="$(DoNotDropScalarValuedFunctions)"
        DoNotDropSearchPropertyLists="$(DoNotDropSearchPropertyLists)"
        DoNotDropSecurityPolicies="$(DoNotDropSecurityPolicies)"
        DoNotDropSequences="$(DoNotDropSequences)"
        DoNotDropServerAuditSpecifications="$(DoNotDropServerAuditSpecifications)"
        DoNotDropServerRoleMembership="$(DoNotDropServerRoleMembership)"
        DoNotDropServerRoles="$(DoNotDropServerRoles)"
        DoNotDropServerTriggers="$(DoNotDropServerTriggers)"
        DoNotDropServices="$(DoNotDropServices)"
        DoNotDropSignatures="$(DoNotDropSignatures)"
        DoNotDropStoredProcedures="$(DoNotDropStoredProcedures)"
        DoNotDropSymmetricKeys="$(DoNotDropSymmetricKeys)"
        DoNotDropSynonyms="$(DoNotDropSynonyms)"
        DoNotDropTables="$(DoNotDropTables)"
        DoNotDropTableValuedFunctions="$(DoNotDropTableValuedFunctions)"
        DoNotDropUserDefinedDataTypes="$(DoNotDropUserDefinedDataTypes)"
        DoNotDropUserDefinedTableTypes="$(DoNotDropUserDefinedTableTypes)"
        DoNotDropUsers="$(DoNotDropUsers)"
        DoNotDropViews="$(DoNotDropViews)"
        DoNotDropXmlSchemaCollections="$(DoNotDropXmlSchemaCollections)"
        DropConstraintsNotInSource="$(DropConstraintsNotInSource)"
        DropDmlTriggersNotInSource="$(DropDmlTriggersNotInSource)"
        DropExtendedPropertiesNotInSource="$(DropExtendedPropertiesNotInSource)"
        DropIndexesNotInSource="$(DropIndexesNotInSource)"
        DropObjectsNotInSource="$(DropObjectsNotInSource)"
        DropPermissionsNotInSource="$(DropPermissionsNotInSource)"
        DropRoleMembersNotInSource="$(DropRoleMembersNotInSource)"
        DropStatisticsNotInSource="$(DropStatisticsNotInSource)"
        ExcludeAggregates="$(ExcludeAggregates)"
        ExcludeApplicationRoles="$(ExcludeApplicationRoles)"
        ExcludeAssemblies="$(ExcludeAssemblies)"
        ExcludeAsymmetricKeys="$(ExcludeAsymmetricKeys)"
        ExcludeAudits="$(ExcludeAudits)"
        ExcludeBrokerPriorities="$(ExcludeBrokerPriorities)"
        ExcludeCertificates="$(ExcludeCertificates)"
        ExcludeClrUserDefinedTypes="$(ExcludeClrUserDefinedTypes)"
        ExcludeColumnEncryptionKeys="$(ExcludeColumnEncryptionKeys)"
        ExcludeColumnMasterKeys="$(ExcludeColumnMasterKeys)"
        ExcludeContracts="$(ExcludeContracts)"
        ExcludeCredentials="$(ExcludeCredentials)"
        ExcludeCryptographicProviders="$(ExcludeCryptographicProviders)"
        ExcludeDatabaseAuditSpecifications="$(ExcludeDatabaseAuditSpecifications)"
        ExcludeDatabaseRoles="$(ExcludeDatabaseRoles)"
        ExcludeDatabaseScopedCredentials="$(ExcludeDatabaseScopedCredentials)"
        ExcludeDatabaseTriggers="$(ExcludeDatabaseTriggers)"
        ExcludeDefaults="$(ExcludeDefaults)"
        ExcludeEndpoints="$(ExcludeEndpoints)"
        ExcludeErrorMessages="$(ExcludeErrorMessages)"
        ExcludeEventNotifications="$(ExcludeEventNotifications)"
        ExcludeEventSessions="$(ExcludeEventSessions)"
        ExcludeExternalDataSources="$(ExcludeExternalDataSources)"
        ExcludeExternalFileFormats="$(ExcludeExternalFileFormats)"
        ExcludeExternalTables="$(ExcludeExternalTables)"
        ExcludeFilegroups="$(ExcludeFilegroups)"
        ExcludeFileTables="$(ExcludeFileTables)"
        ExcludeFullTextCatalogs="$(ExcludeFullTextCatalogs)"
        ExcludeFullTextStoplists="$(ExcludeFullTextStoplists)"
        ExcludeLinkedServerLogins="$(ExcludeLinkedServerLogins)"
        ExcludeLinkedServers="$(ExcludeLinkedServers)"
        ExcludeLogins="$(ExcludeLogins)"
        ExcludeMessageTypes="$(ExcludeMessageTypes)"
        ExcludePartitionFunctions="$(ExcludePartitionFunctions)"
        ExcludePartitionSchemes="$(ExcludePartitionSchemes)"
        ExcludeQueues="$(ExcludeQueues)"
        ExcludeRemoteServiceBindings="$(ExcludeRemoteServiceBindings)"
        ExcludeRoutes="$(ExcludeRoutes)"
        ExcludeRules="$(ExcludeRules)"
        ExcludeScalarValuedFunctions="$(ExcludeScalarValuedFunctions)"
        ExcludeSearchPropertyLists="$(ExcludeSearchPropertyLists)"
        ExcludeSecurityPolicies="$(ExcludeSecurityPolicies)"
        ExcludeSequences="$(ExcludeSequences)"
        ExcludeServerAuditSpecifications="$(ExcludeServerAuditSpecifications)"
        ExcludeServerRoleMembership="$(ExcludeServerRoleMembership)"
        ExcludeServerRoles="$(ExcludeServerRoles)"
        ExcludeServerTriggers="$(ExcludeServerTriggers)"
        ExcludeServices="$(ExcludeServices)"
        ExcludeSignatures="$(ExcludeSignatures)"
        ExcludeStoredProcedures="$(ExcludeStoredProcedures)"
        ExcludeSymmetricKeys="$(ExcludeSymmetricKeys)"
        ExcludeSynonyms="$(ExcludeSynonyms)"
        ExcludeTables="$(ExcludeTables)"
        ExcludeTableValuedFunctions="$(ExcludeTableValuedFunctions)"
        ExcludeUserDefinedDataTypes="$(ExcludeUserDefinedDataTypes)"
        ExcludeUserDefinedTableTypes="$(ExcludeUserDefinedTableTypes)"
        ExcludeUsers="$(ExcludeUsers)"
        ExcludeViews="$(ExcludeViews)"
        ExcludeXmlSchemaCollections="$(ExcludeXmlSchemaCollections)"
        GenerateSmartDefaults="$(GenerateSmartDefaults)"
        IgnoreAnsiNulls="$(IgnoreAnsiNulls)"
        IgnoreAuthorizer="$(IgnoreAuthorizer)"
        IgnoreColumnCollation="$(IgnoreColumnCollation)"
        IgnoreComments="$(IgnoreComments)"
        IgnoreCryptographicProviderFilePath="$(IgnoreCryptographicProviderFilePath)"
        IgnoreDdlTriggerOrder="$(IgnoreDdlTriggerOrder)"
        IgnoreDdlTriggerState="$(IgnoreDdlTriggerState)"
        IgnoreDefaultSchema="$(IgnoreDefaultSchema)"
        IgnoreDmlTriggerOrder="$(IgnoreDmlTriggerOrder)"
        IgnoreDmlTriggerState="$(IgnoreDmlTriggerState)"
        IgnoreExtendedProperties="$(IgnoreExtendedProperties)"
        IgnoreFileAndLogFilePath="$(IgnoreFileAndLogFilePath)"
        IgnoreFilegroupPlacement="$(IgnoreFilegroupPlacement)"
        IgnoreFileSize="$(IgnoreFileSize)"
        IgnoreFillFactor="$(IgnoreFillFactor)"
        IgnoreFullTextCatalogFilePath="$(IgnoreFullTextCatalogFilePath)"
        IgnoreIdentitySeed="$(IgnoreIdentitySeed)"
        IgnoreIncrement="$(IgnoreIncrement)"
        IgnoreIndexOptions="$(IgnoreIndexOptions)"
        IgnoreIndexPadding="$(IgnoreIndexPadding)"
        IgnoreKeywordCasing="$(IgnoreKeywordCasing)"
        IgnoreLockHintsOnIndexes="$(IgnoreLockHintsOnIndexes)"
        IgnoreLoginSids="$(IgnoreLoginSids)"
        IgnoreNotForReplication="$(IgnoreNotForReplication)"
        IgnoreObjectPlacementOnPartitionScheme="$(IgnoreObjectPlacementOnPartitionScheme)"
        IgnorePartitionSchemes="$(IgnorePartitionSchemes)"
        IgnorePermissions="$(IgnorePermissions)"
        IgnoreQuotedIdentifiers="$(IgnoreQuotedIdentifiers)"
        IgnoreRoleMembership="$(IgnoreRoleMembership)"
        IgnoreRouteLifetime="$(IgnoreRouteLifetime)"
        IgnoreSemicolonBetweenStatements="$(IgnoreSemicolonBetweenStatements)"
        IgnoreTableOptions="$(IgnoreTableOptions)"
        IgnoreUserSettingsObjects="$(IgnoreUserSettingsObjects)"
        IgnoreWhitespace="$(IgnoreWhitespace)"
        IgnoreWithNocheckOnCheckConstraints="$(IgnoreWithNocheckOnCheckConstraints)"
        IgnoreWithNocheckOnForeignKeys="$(IgnoreWithNocheckOnForeignKeys)"
        IncludeCompositeObjects="$(IncludeCompositeObjects)"
        IncludeTransactionalScripts="$(IncludeTransactionalScripts)"
        NoAlterStatementsToChangeCLRTypes="$(NoAlterStatementsToChangeCLRTypes)"
        PopulateFilesOnFileGroups="$(PopulateFilesOnFileGroups)"
        RegisterDataTierApplication="$(RegisterDataTierApplication)"
        ScriptDatabaseCollation="$(ScriptDatabaseCollation)"
        ScriptDatabaseCompatibility="$(ScriptDatabaseCompatibility)"
        ScriptDatabaseOptions="$(ScriptDatabaseOptions)"
        ScriptDeployStateChecks="$(ScriptDeployStateChecks)"
        ScriptFileSize="$(ScriptFileSize)"
        ScriptNewConstraintValidation="$(ScriptNewConstraintValidation)"
        ScriptRefreshModule="$(ScriptRefreshModule)"
        TargetDatabaseName="$(TargetDatabaseName)"
        TreatVerificationErrorsAsWarnings="$(TreatVerificationErrorsAsWarnings)"
        UnmodifiableObjectWarnings="$(UnmodifiableObjectWarnings)"
        VerifyCollationCompatibility="$(VerifyCollationCompatibility)"
        VerifyDeployment="$(VerifyDeployment)"
        &gt;
        &lt;Output TaskParameter="IntermediateFileWrites" ItemName="FileWrites"/&gt;
      &lt;/SqlBuildTask&gt;
  
  On our previous sprint, the build and deploy of the project was working fine. When I did a TFS compare with the previous version there are no major differences.
  </code></pre>
  
  <p>This is what I have done already:</p>
  
  <ul>
  <li><p>I have upgraded SSDT to the most recent version (didn't fix it)</p></li>
  <li><p>deleted the Microsoft.Data.Tools.Schema.SqlTasks.targets file and repair the ssdt instalation (didn't fix it either)</p></li>
  </ul>
  
  <p>I am still looking for any duplicated keys in the targets file as the exception points out</p>
  
  <p>Any help will be greatly appreciated...</p>