Search code examples
web-deploymentmsdeploywebdeploydacpac

MSDeploy/WebDeploy - Deploy Composite Database Project via DacPac


We have a database project with views which join to tables in another database. The other database is in a different solution. This failed to build until we added a reference to a DacPac from the other database. I believe these views are considered “Composite Database Objects” because they reference objects not included as scripts in the database but rather referenced in the DacPac. We can successfully deploy this project from the VS to the target database.

Now we are trying to automate the deployment via MSDeploy. We have successfully deployed non-Composite database projects using DacPacs in the past by creating a package from a manifest. For example:

But in this case the deployment fails with the following error:

Error SQL0: The reference to external elements from the source named 'Other.dacpac' could not be resolved, because no such source is loaded. Warning SQL72025: No file was supplied for reference Other.dacpac; deployment might fail. When package was created, the original referenced file was located D:\BUILDS\6\CORE SERVICES\ACME DB (DEV2-DEPLOY)\SOURCES\ACME.SQLDEPLOY\DACPACS\Other.DACPAC.

Error: An error occurred while adding references. Deployment cannot continue. Error count: 1.

Is there a trick to make sure the referenced DacPac makes it into the package and the deployment completes successfully?


Solution

  • In the end we had to:

    • Unzip the DacPac
    • Change the path of the referenced DacPac to be relative
    • Recalculate the checksum and update it
    • Rezip the DacPac

    Not ideal, but in the end we now have an automated deployment process for DacPac referencing DacPacs.