Search code examples
wixinstallationwindows-installer

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"?


Solution

  • Nevermind, I found the solution:

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