安装过程中,有时候需要根据用 户的设置来进行不同的安装,其中一个方面就是根据用户选择安装的 Feature 或者 Component ,来判断下一步的操作。
Wix 中提供了相关的判断方法和内置的状态值。
Prepending some special characters to the names will give them extra meaning:
% environment variable (name is case insensitive)
$ action state of component
? installed state of component
& action state of feature
! installed state of feature
The last four can return the following integer values:
-1 no action to be taken
1 advertised (only for components)
2 not present
3 on the local computer
4 run from the source
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.