CustomAction "UpdateFeaturesInstallStates" restore removed Features - Advanced Installer Community
rmoc
Posts: 72
Joined: Tue Mar 14, 2017 8:27 pm

CustomAction "UpdateFeaturesInstallStates" restore removed Features

In my setup, I have several features that I do not want to install when not needed via the command line.
For this, I use the following command line.
Ok.png
Ok.png (34.62 KiB) Viewed 2490 times
I now use the custom action “UpdateFeaturesInstallStates” to apply changes to the feature states that may be triggered by another custom action.
However, when I call the “UpdateFeaturesInstallStates” custom action, my command-line parameter REMOVE is ignored, and App1 is installed anyway.
Error.png
Error.png (41.52 KiB) Viewed 2490 times
Example project:
RemoveFeature.zip
(4.98 KiB) Downloaded 95 times
Catalin
Posts: 7847
Joined: Wed Jun 13, 2018 7:49 am

Re: CustomAction "UpdateFeaturesInstallStates" restore removed Features

Hello Rene,

This custom action is mostly used for the following scenario: you have a feature that is installed based on a condition (e.g. a property has a specific value) and that property is set after the features have been evaluated.

In this case, we need to update the features' states so that it can reflect the new condition, e.g.:

feature_A requires PROP_A to have a value of "true"

PROP_A is not set just yet and feature_A has its' state set to "do not install" because the condition is false

we then execute a custom action that sets PROP_A to "true"

but in the above case, the feature_A will still not be installed due to the fact that it was previously set so. So we use the UpdateFeatureState custom action so that the condition is evaluated again.

In your case, there is no condition to evaluate here, so that custom action will set your features to always install.

You've set APP1 to not install "correctly" (well, not quite correctly - I'll elaborate later) via the REMOVE property. So when the custom action is executed, the feature condition for APP1 will be evaluated once again and since it has no condition attached to it, it will always think that it should be installed.

Now, why I said it's not quite correct - the REMOVE property is mostly used for uninstall. As per MSFT documentation:
The value of the REMOVE property is a list of features delimited by commas that are to be removed.
So, instead of that, you could just use ADDLOCAL with the features that you want installed, e.g.:

Code: Select all

setup.exe ADDLOCAL=APP2,CORE1,CORE2
Now, comming back to your "issue", that's not quite an "issue" but rather how the custom actions works.

I understand that your scenario is more complex than the sample project, but if you give me some more details I will perhaps be able to help you more here.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rmoc
Posts: 72
Joined: Tue Mar 14, 2017 8:27 pm

Re: CustomAction "UpdateFeaturesInstallStates" restore removed Features

Hello Catalin,

thank you for the detailed explanation. I will try to avoid using “UpdateFeaturesInstallStates” or look for another way to disable the features via command line.

Regards,
René
Catalin
Posts: 7847
Joined: Wed Jun 13, 2018 7:49 am

Re: CustomAction "UpdateFeaturesInstallStates" restore removed Features

You are always welcome, René! :)

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”