We've already used conditional expressions, among others, in Condition
and Publish
tags. We are already aware of logical operators like NOT
, AND
, OR
or comparisons like <
, >
, =
. To have them all described, here they are in order of precedence:
Note that---as usual in XML---you have to be cautious when you use angle brackets that can be mistaken for an opening or closing character of an XML tag. To avoid confusion, you should use XML's character data mechanism to escape these conditions: Wrap conditional expressions with <![CDATA[
and ]]>
:
<![CDATA[IAgree <> "Yes"]]>
The safest approach would be to wrap everything (this is what the WiX decompiler, Dark, does) but---at least in my humble opinion---this makes the source far too illegible. Or, you have to take care of which expressions are misleading and which are not (the compiler will give an error message if it doesn't understand something) and only use the wrapper where really necessary. It's your choice.
In these expressions, you can use property names (remember that they are case sensitive). Non-existent property names will be treated as empty strings. The logical value of a property reflects whether it has been set---meaning that you cannot check for a logical value by simply using the property:
Prepending some special characters to the names will give them extra meaning:
The last four can return the following integer values:
A few examples to make things clearer:
(&FeatureName = 3) AND NOT (!FeatureName = 3)
Run action only if the product will be installed locally. Do not run action on a reinstallation.
The term &FeatureName = 3
means the action is to install the feature locally.
The term NOT (!FeatureName = 3)
means the feature is not installed locally.(&FeatureName = 2) AND (!FeatureName = 3)
Run action only if the feature will be uninstalled.
This condition only checks for a transition of the feature from an installed state of local to the absent state.(?ComponentName = 3) AND ($ComponentName = 2 OR $ComponentName = 4)
Run action only if the component was installed locally, but is transitioning out of state.
The term ?ComponentName = 3
means the component is installed locally.
The term $ComponentName = 2
means that the action state on the component is absent.
The term $ComponentName = 4
means that the action state on the component is run from source. Note that an action state of advertise is not valid for a component.?ComponentName = $ComponentName
Run action only on the reinstallation of a component.