Categories: Azure Devops

Error – Reference to external ‘master.dacpac’ could not be resolved when deploying dacpac in Azure Devops

I have a database project in Visual Studio. Inside the database, I use a couple of system views to fetch some metadata about tables. To make the project build successfully, you need to add a reference to the master database in the project.

I created a build pipeline in Azure Devops, which builds the Visual Studio solution (which creates the dacpac of the database), then copies the dacpac and a publish profile to the artifact staging folder, publishes those and finally deploys the database (using the dacpac and the publish profile) to the dev server. This looks like this (yes I use the classic editor):

It all works without a problem. I then created a release pipeline to deploy the same dacpac of my data warehouse to another environment (this can be QA or production). I essentially used the same last step as in the build pipeline – the Azure SQL DB deployment task – but instead of using the artifact staging directory, I used the published resources. This time however, the deployment did not succeed. I was greeted with the error “[error]Error SQL0: The reference to external elements from the source named ‘master.dacpac’ could not be resolved, because no such source is loaded.“.

The error makes sense: I have a reference to a database called master in my project, so sqlpackage.exe (the process that does the actual deployment) is going to look for a dacpac called master.dacpac. But it isn’t present in the published resources of the build pipeline. When you build the project in Visual Studio, this dacpac is created as well.

The resolve this issue, you simply have to copy this dacpac to the artifact staging directory as well.

You don’t have to do anything special with it, it just needs to be there when sqlpackage.exe wants to deploy your database dacpac. The only thing bothering me is that my build pipeline was succeeding even though I did not copy the master dacpac to the artifact staging directory. Why wasn’t it complaining about a missing master.dacpac over there? If you have any idea, let me know in the comments.


------------------------------------------------
Do you like this blog post? You can thank me by buying me a beer 🙂
Koen Verbeeck

Koen Verbeeck is a Microsoft Business Intelligence consultant at AE, helping clients to get insight in their data. Koen has a comprehensive knowledge of the SQL Server BI stack, with a particular love for Integration Services. He's also a speaker at various conferences.

Recent Posts

Free webinar – Tackling the Gaps and Islands Problem with T-SQL Window Functions

I'm hosting a free webinar at MSSQLTips.com at the 19th of December 2024, 6PM UTC.…

5 days ago

dataMinds Connect 2024 – Session Materials

The slides and scripts for my session "Tackling the Gaps & Islands Problem with T-SQL…

4 weeks ago

Connect to Power BI as a Guest User in another Tenant

Sometimes your Microsoft Entra ID account (formerly known as Azure Active Directory) is added as…

2 months ago

How to use a Script Activity in ADF as a Lookup

In Azure Data Factory (ADF, but also Synapse Pipelines and Fabric Pipelines), you have a…

4 months ago

Database Build Error – Incorrect syntax near DISTINCT

I wrote a piece of SQL that had some new T-SQL syntax in it: IS…

4 months ago

Speaking at dataMinds Connect 2024

I'm very excited to announce I've been selected as a speaker for dataMinds Connect 2024,…

5 months ago