11

I am building a database dacpac using sqlpackage on a windows machine. The project contains a reference to master.dacpac

I take the move the dacpac to a linux machine (mssql-server-linux docker image) and restore the database.

deploy-database.sh

# publish dacpac using sqlpackage
./sqlpackage/sqlpackage /Action:Publish /sf:"/MyDb.dacpac" /tu:sa /tp:Password1 /tdn:MyDb /tsn:localhost

Error:

No file was supplied for reference master.dacpac; deployment might fail. When package was created, the original referenced file was located C:$(windows machine path)\MASTER.DACPAC. Initializing deployment (Failed) An error occurred during deployment plan generation. Deployment cannot continue. Error SQL0: The reference to external elements from the source named 'master.dacpac' could not be resolved, because no such source is loaded. Warning SQL72025: No file was supplied for reference master.dacpac; deployment might fail. When package was created, the original referenced file was located C:$(windows machine path)\MASTER.DACPAC.

An error occurred while adding references. Deployment cannot continue. The command '/bin/sh -c sh /deploy-database.sh' returned a non-zero code: 1

I have tried adding master.dacpac to the project directly and also copying it to the docker image but the same error occurs.

How can I restore a dapac in a linux environment that has a reference to master.dacpac?

Hadi
  • 36,233
  • 13
  • 65
  • 124
Eamonn McEvoy
  • 8,876
  • 14
  • 53
  • 83
  • Even if you copy `master.dacpac` to the same folder as `mydb.dacpac` and run sqlpackage with `/p:IncludeCompositeObjects=true` it still fails? – Jorge Candeias Mar 21 '19 at 22:57

2 Answers2

2

I had a similar issue, my solution was to rename the dacpac files UPPERCASE, (ex: MASTER.DACPAC) which worked for me, as well as making the directory with the dacpac files the working directory.

Tracker1
  • 19,103
  • 12
  • 80
  • 106
1

I have tried adding master.dacpac to the project directly and also copying it to the docker image but the same error occurs.

Make sure master.dacpac file is in the current working directory. Since your MyDb.dacpac file exists in the root directory, copy the master.dacpac file there and execute the sqlpackage command in the context of the root directory.

The example below specifies an absolute reference to sqlpackage (in case it's not already in your path) and a relative reference to your user dacpac (although an absolute reference will work too).

cd /
/sqlpackage/sqlpackage /Action:Publish /sf:"MyDb.dacpac" /tu:sa /tp:Password1 /tdn:MyDb /tsn:localhost
Dan Guzman
  • 43,250
  • 3
  • 46
  • 71
  • I'm not directly working on this anymore. If someone can confirm this fixes the issue, I will accept as the answer. @tgn12 could you comment here if this fixed it for you? – Eamonn McEvoy Mar 26 '19 at 14:19
  • @EamonnMcEvoy, I did test this and the db was successfully deployed. However, if you can't test yourself and want independent verification, that's fine. – Dan Guzman Mar 26 '19 at 15:19
  • 2
    NOTE: for my own projects, I had to rename the other referenced files to all-caps, based on the error output... such as MYFOO.DACPAC and MASTER.DACPAC in the directory I was using. – Tracker1 Apr 15 '20 at 15:13
  • 1
    @Tracker1 - making the filename MASTER.DACPAC case sensitive is the answer – BozoJoe May 04 '20 at 16:36