I'm a novice WiX user, converting over several existing installations from a no longer maintained (.MSI-producing) commercial product.
As part of that I'm restructuring the original feature/component arrangements to take advantage of some of the new options WiX has opened up. One of these is adding Conditions at Feature rather than Component level, and as part of that I've tried specifying a conditional Feature like this (demo/test items throughout):
<Feature Id="Feature1" Title="Test Only" Level="0">
<Component Id="C1" Guid="*" Directory="SomeDir">
<File Id="File1" KeyPath="yes" Checksum="yes" Name="Test file.txt" Source="D:\xxx.dat" />
</Component>
<Condition Level="1"><![CDATA[INSTALLTYPE <> 1]]></Condition>
</Feature>
Where INSTALLTYPE
is a Property defined at <Product>
level and subsequently set to 0, 1 or 2 by the user via a RadioButtonGroup
in the UI sequence.
Summarising what I've found after a day or so of trying different options and head-scratching:
- With an initial
Level=0
, set to 1 by the condition (as in the sample above), the Feature is never installed. - With an initial
Level=1
, set to 0 by the condition, the Feature is installed when the condition is satisfied as long as an=
test is used in the condition. If aINSTALLTYPE <> 1
is used, orNot (INSTALLTYPE = 1)
, the feature is never installed. - If a pre-defined Property (such as
INSTALLLEVEL
) is used in the test rather than myINSTALLTYPE
, everything works correctly/as expected. - If equivalent tests are applied at Component, rather than Feature, level, everything works as expected for all Propertys and test operators.
Something seems to be going wrong with INSTALLTYPE
but I can't for the life of me work out what. I've tried firing a VBScript custom action (MsgBox("INSTALLTYPE=" & Session.Property("INSTALLTYPE"))
) in the Execute sequence to check the value of the Property, and as far as I can see this does display the value I'd expect it to have from the UI setting.
In principle I could get Features installing the way I want using the subset of settings I've found to work (e.g. INSTALLTYPE = 0 OR INSTALLTYPE = 2
rather than INSTALLTYPE <> 1
), but my bafflement over apparently simple things not behaving as expected suggests I'm missing something fundamental...so I'm wary of just shrugging and applying workarounds.
If anyone has any thoughts on what I might be doing wrong with the items above, I'd be very happy to hear them!