0

I'm using Octopus deploy and DacPac to deploy a database twice on the same server. They have different names and are deployed successfully. Only in the publish command I give them different values for the same variable, but they both use the second value.

Deploy.ps1:

print 'deploying first'
& SqlPackage.exe /a:Publish /sf:$DacPacFile /tcs:$ConnectionString /v:SchemaName="First"
print 'deploying second'
& SqlPackage.exe /a:Publish /sf:$DacPacFile /tcs:$ConnectionString /v:SchemaName="Second"

Both end up using the value Second. So it seems the second one is somehow overwriting the second one. There is a postscript that prints the value of SchemaName in the text: using '$(SchemaName)' And the console printouts are in sequence as follows:

deploying first
using Second
deploying second
using Second

The default value of the SQLCMD variable was Second, so I changed that to Third and the default value is ignored, as it should be.

Edit:
I realized it creates one dacpac file that is used in both deployments. This matters for how the variables are used. Because they are used to include other .sql files in the deployment.

So I need one dacpac file per publish.

MrFox
  • 4,852
  • 7
  • 45
  • 81

1 Answers1

0

I was using the variable to dynamically load in different scripts that would be executed. But I should have been using the variable in the script directly to determine behaviour if-else style. Otherwise usage of the variable get's baked in the dacpac file.

Community
  • 1
  • 1
MrFox
  • 4,852
  • 7
  • 45
  • 81