Using the WIX DacPac Installer - Steve0212a/WIXDacPacInstaller GitHub Wiki

Step #1

First, to use the WIX DacPac Installer, you have to create a property that contains all the parameters for the extension.

Note: the Property Name must match the name of the custom action defined in Step #2.

<!-- Create a custom action to run first and set up all the parameters that are -->
<!-- passed to the Wix DacPac Extension.  The property name MUST MATCH -->
<!-- the name of the custom action that executes the binary defined above. -->
<!-- The parameters in the Value property are semi-colon delimited. -->
<CustomAction
     Id="SetupDacPacWIXDacPacInstallerExampleCustomAction"
     Property="DacPacWIXDacPacInstallerExampleCustomAction" 
     Value="ShowUI=True;SqlPackagePath=c:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\SqlPackage.exe;DacPacPath=[INSTALLFOLDER]WIXDacPacInstallerExample.dacpac;LogFilePath=[TempFolder]\WIXDacPacInstallerExample.dacpac.log;TargetServerName=[DATABASESERVER];TargetDatabaseName=WIXDacPacInstallerExample;OtherParameters=/p:RegisterDataTierApplication=True /p:BlockWhenDriftDetected=False /p:BlockOnPossibleDataLoss=False"
/>

Step #2

Next, define the custom action that will actually perform the execution of SQLPackage.exe. Be sure to have done the "Wix Project Setup" above as it will be referenced in this step.

Note: the Execute parameter is set to Deferred. This is required.

Step #3

Lastly, you must include the custom actions to be executed. While this is not specific to the WIX DacPac Installer, it is included for completeness.

 <InstallExecuteSequence>
      <!--
           the custom actions must be added to the execute sequence.  The setup custom
           action MUST be run prior to the Dac Pac Installer custom action. 
      -->
      <Custom
           Action="SetupDacPacWIXDacPacInstallerExampleCustomAction"  
           Before="DacPacWIXDacPacInstallerExampleCustomAction">
                NOT Installed AND NOT REMOVE AND <![CDATA[&DatabaseFeature=3]]>
      </Custom>
      <Custom
           Action="DacPacWIXDacPacInstallerExampleCustomAction"
           After="InstallFiles">
                NOT Installed AND NOT REMOVE AND <![CDATA[&DatabaseFeature=3]]>
      </Custom>
 </InstallExecuteSequence>

Parameters

Below is the list of parameters that can be passed in Step #2 above.

Parameter Name Required Default Value Description
Action No Publish This property will be passed to SqlPackage.exe using the /Action: parameter
SqlPackagePath Yes N/A This property will contain the full path to SqlPackage.exe. A future release may attempt to find it, but for now, it must be specified.
DacPacPath Yes N/A This property will contain the full path to the *.DacPac file. This path can be a deployed file.
KeepOpenOnError No FALSE If ShowUI is set to true, the form will stay open when complete if there was an error. If ShowUI is false, this parameter has no effect.
LogFilePath Yes N/A This property will contain the full path to where the log file should be stored.
TargetServerName Yes N/A This property will contain the SQL Server name. It will be passed to SqlPackage.exe using the /TargetServerName: parameter.
TargetDatabaseName Yes N/A This property will contain the SQL Server database name. It will be passed to SqlPackage.exe using the /TargetDatabaseName: parameter.
OtherParameters Yes N/A This property will contain any additional parameters that should be included on the command line of SqlPackage.exe. Anything can be specified in this parameter, but it will be directly passed to the command line of SqlPackage.exe.
ShowUI No FALSE If true, a window will be shown that shows the output of SqlPackage.exe in real time as it is running.
UiTitle No Installation of DB If the UI, is shown, this is the title of the window.
⚠️ **GitHub.com Fallback** ⚠️