I'm using wix to build an installer that installs different features based on a "CURRENCY" property passed in from the command line.
msiexec /i install.msi CURRENCY="GBP"
Here is the feature element of the wix file:
<Feature Id="Complete" Level="1" Title="My Service" Display="expand" InstallDefault="local">
<Feature Id="MainProgram" Title="My Service" Display="expand" Level="1" Absent="allow">
<ComponentRef Id="MyCoordinator" />
<Feature Id="Foo" Title="Foo" Display="expand" InstallDefault="followParent" Level="1" Absent="disallow">
<Feature Id="UK" Title="UK Settings" Description="UK Plugin." Level="0" InstallDefault="followParent" Absent="disallow">
<Condition Level="1">CURRENCY = "GBP"</Condition> <<-- CONDITION
<ComponentRef Id="UK_Settings_Component" />
</Feature>
<Feature Id="US" Title="US Settings" Description="US Plugin." Level="0" InstallDefault="followParent" Absent="disallow">
<Condition Level="1">CURRENCY = "USD"</Condition> <<-- CONDITION
<ComponentRef Id="US_Settings_Component" />
</Feature>
</Feature>
</Feature>
</Feature>
The install process works great. I pass in a currency and get the appropriate country's settings component installed.
But when I try to uninstall the application through the "add or remove programs" applet, it requires the user to uninstall the application twice before removing it from the list of installed programs. So I ran the uninstall from the command line with verbose logging.
> msiexec /x {product-guid} /L*v "uninstall_1.txt"
> msiexec /x {product-guid} /L*v "uninstall_2.txt"
After digging through the verbose uninstall log, I believe this is because the installer is failing to remove the currency specific settings component.
From the uninstall log after the second uninstall I can see that it found:
Component: UK_Settings_Component; Installed: Local; Request: Null; Action: Local
If I pass in the the currency to the uninstall command, it only requires one uninstall
> msiexec /x {product-guid} CURRENCY="GBP"
Question: How do I tell it to always remove all currency components when uninstalling the application?
CodePudding user response:
Make sure features are always enabled so they can be removed:
The solution is easy, though: Add
OR REMOVE
to the condition that enables the feature. That ensures the feature is enabled during whole-product uninstall or an attempt to remove that particular feature.