Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wix Boolean Property Values Don't Work

I have the following property:

<Property Id="UPDATEDB">1</Property>

A checkbox in the UI bound to that property:

<Control Id="updateDatabase" Type="CheckBox" CheckBoxValue="1" Height="15" Width="95" X="20" Y="74" Text="Update Database" Property="UPDATEDB" />

And a Custom Action which does something based on the value of this property

<CustomAction Id="RunDbMigration" Directory="INSTALLDIR" Return="check"
          ExeCommand='[DBMIGRATIONDIR]\DbMigration.exe' />

<InstallExecuteSequence>
  <Custom Action="RunDbMigration" After="InstallFinalize">UPDATEDB=1 AND NOT Installed</Custom>
</InstallExecuteSequence>

If I try to pass a value of 0 for UPDATEDB from the command line:

msiexec /i "Setup.msi" /l* UPDATEDB=0

or

msiexec /i "Setup.msi" /l* UPDATEDB="0"

the value of the checkbox is checked anyway. That said, the 0 passed in seems to be respected and the RunDbMigration action is not run...

What's going on here? Why is this such rocket science?

like image 991
Jeff Avatar asked Oct 02 '11 03:10

Jeff


3 Answers

As others have mentioned, Checkboxes are not boolean in a 1/0 sense, they're boolean in a null/not-null sense.

To unset from the command line - you would want to use something like

msiexec /i "Setup.msi" /l* UPDATEDB=""

Chances are that your condition is looking specifically for the value of 1 before executing your custom action, which is why your CA isn't being run.

like image 119
saschabeaumont Avatar answered Nov 06 '22 16:11

saschabeaumont


Installer properties are either set to a value or they are not set. Internally the value is just a string, so "0", "1", "true" and "false" are the same.

A checkbox control is checked when its property is set to a value (doesn't matter what) and unchecked when its property is empty.

This command line sets the property and checks the checkbox:

msiexec /i "Setup.msi" /l* UPDATEDB="0"

This command line doesn't set the property, so the checkbox is not checked:

msiexec /i "Setup.msi" /l*
like image 43
rmrrm Avatar answered Nov 06 '22 16:11

rmrrm


The problem is the CheckBoxValue="1". You find the solution for your question here: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/How-to-conditionally-check-uncheck-a-checkbox-td5539262.html

like image 2
Morten Frederiksen Avatar answered Nov 06 '22 17:11

Morten Frederiksen