I'm configuring upgrades like this:
c#
project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
project.MajorUpgradeStrategy.UpgradeVersions.MigrateFeatures = true;
When an upgrade is done, Windows Installer appears to behave as expected, as far as I can tell from the logs.
However, in custom actions I'm unable to determine which features are selected - session["ADDLOCAL"] is always empty, and as a result of course Session.IsFeatureEnabled(FEATURE_ID) is always false.
Is there any way to determine what features are installed in a custom action during an upgrade?
It is an interesting problem. Remember, we have found that ADDLOCAL is used to pass the user input (ticks in checkboxes) to control which features are installed. But in case of no user input the property is empty.
I am not sure where and how WiX/MSI keeps the installed features information but something tells me it does.
If you are not in deferred (elevated) CA you can always try and see if e.Session.Features has it.
And if it does then I will speedup delivery of #737 which then can be used in a new extension method session.IsFeatureInstalled(id).
Finding right semantics of the method names can be a challenge:
session.IsFeatureInstalled(id) - product is installed (or being upgraded) and the feature is toosession.IsFeatureEnabled(id) - product is being installed and the feature is selected by the user for the installation. Based on ADDLOCAL but falls back to WixSharp ADDFEATURES in deferred actions.But let's see if my guess about session.Features during upgrade is right.
Hah, totally forgot that I'd previous opened the related #737!
You are correct, e.Session.Features does have feature states, and with managed UI they are available in the BeforeInstall action.
Most helpful comment
Hah, totally forgot that I'd previous opened the related #737!
You are correct,
e.Session.Featuresdoes have feature states, and with managed UI they are available in theBeforeInstallaction.