Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have a WiX Property default to null?

I am working on a set of WiX installers that are going to share a common form. Every application needs the values set, but they are going to be different for each application.

I am trying to allow for the properties (which are linked to controls) to have a default value (or not) and to allow for the property values to be set via command line.

in my "SharedDialog.wxs" I have:

<Fragment>
   <PropertyRef Id="PROP1"/>
   <PropertyRef Id="PROP2"/>
   <UI>
      <Dialog Id="SharedDialog" Width="370" Height="270" Title="[ProductName]">
         <Control Type="Edit" Id="1" Property="PROP1" Wid... Indirect="no" />
         <Control Type="CheckBox" Id="2" Property="PROP2" Wid...  
           CheckBoxValue="1" Indirect="no"/>
      </Dialog>
</Fragment>

In a file for the application specific project:

<Fragment>
   <Property Id="PROP1" Value="Test"/>
   <Property Id="PROP2" Value="1"/>
</Fragment>

This all works for what I am trying to do, but the problem is that when I want to clear the values as so: (so they don't have a default)

<Fragment>
   <Property Id="PROP1"/>
   <Property Id="PROP2"/>
</Fragment>

I get this error:

Unresolved reference to symbol 'Property:PROP1' in section 'Fragment:'. 
Unresolved reference to symbol 'Property:PROP2' in section 'Fragment:'.

WiX also will not let you set value to "". The problem is that as far I can tell the checkbox will always be checked if the property has a value. How can I set the property "PROP2" to "null"?

like image 409
dspiegs Avatar asked Oct 20 '25 04:10

dspiegs


2 Answers

  • You can undefine an existing property by setting it equal to an empty string wrapped in braces like this: PROPERTY = {} in a set property custom action. This means the property doesn't exist, it is not an empty string. See the explanation here.
  • For properties to be available from the command line they must be PUBLIC - they are the properties that are all UPPERCASE.
  • Setting PUBLIC PROPERTIES secure means they can be passed from the client to the server installation process which is required for properties that are used in deferred mode custom actions. Technically this adds them to the list of SecureCustomProperties.
  • You can give PUBLIC PROPERTIES a default value in the Property table, and then set other values from the command line. The command line overrides the defaults:

    msiexec.exe /I "C:\Test.msi" /QN /L*V "C:\log.log" TEST="MyValue" TEST2="MyValue"

See more info: How to set a check box to "unchecked" from the msiexec command line?

like image 200
Stein Åsmul Avatar answered Oct 23 '25 12:10

Stein Åsmul


Nevermind, I found the solution:

<Fragment>
   <Property Id="PROP1" Secure="yes"/>
   <Property Id="PROP2" Secure="yes"/>
</Fragment>
like image 36
dspiegs Avatar answered Oct 23 '25 10:10

dspiegs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!