Hello Abdul,
The "feature will be installed when required" option is intended to be used for advertised features. The installation resources of advertised features are not installed when the "feature will be installed when required" option is used. In this case the feature resources will be deployed on target machine when a product self-repair will be triggered, for instance through an
advertised shortcut.
Now, getting back to your requirement, to preserve on upgrade a feature installation state even when the customer explicitly chose not to install it, you can try to develop two custom actions:
1. one custom action which will get the related feature installed state and set an installer property with a specific value
2. a second custom action which will set the feature installation state depending on the
installer property specific value
The first action could be scheduled before "Wizard Dialogs Stage -> User Selection" actin group, while the second one could be scheduled after "Install Execution Stage -> Searches" action group.
Here are some article references which should be useful to read for getting a starting point for your custom action implementation:
1.
How to set an installer property using custom actions
2.
Session.FeatureCurrentState property
3.
Session.FeatureRequestState property
4.
MsiQueryFeatureStateA function
5.
MsiSetFeatureStateA function
Hope this helped.
All the best,
Daniel