0
votes

I have a product that consists of several features (A, B, C), all of which share a common windows-service component. The catch is that there is an end case: if only one specific feature is installed (feature C), with a 'legacy-mode' flag (some property that is saved in the registry), then this windows-service component either should not be installed or its startup type should be changed from 'automatic' to 'disabled'. I would prefer the 'not installed' solution to the disabled startup type solution.

In all other cases: when other features (A,B) are installed besides this feature (C), or when the 'legacy-mode' flag is not set - the windows-service component should be installed and its startup type should be set to 'automatic'.
If the product is reconfigured the condition should be reevaluated and acted upon appropriately for both scenarios.

The problem is that it is not possible to use features' install-states in the windows-service component condition, since both features' install-state and component's condition are evaluated in the same CostFinalize action (See: http://www.joyofsetup.com/2008/04/09/feature-states-in-component-conditions/) Also, using the approach of removing the component in a custom action does not work, because non-transitive components cannot be removed from existing features unless this is a major-upgrade(See http://blogs.msdn.com/b/heaths/archive/2010/02/15/test-your-conditions.aspx)

I could separate the component to a different feature of its own and try to write custom action that sets this feature's install-state based on the other features' install-states after the CostFinalize operation, but that seams to complicate the installation logic for the different scenarios (install, reconfigure, rollback, uninstall) and make it more error-prone.

What would you suggest?

1
If your comment fixed your problem, you should post it as an answer and accept it, so others can more easily find their solution should they have a similar issue.Netfangled
Alright I did it now. Thanks.Dima G

1 Answers

0
votes

Eventually I created a child feature to feature C that contained only the windows-service component, and I control its install-state with two MsiSetFeatureState custom actions that are scheduled after CostFinalize - one to set the state to absent in case feature C is installed or reconfigured and the 'legacy-mode' flag is set, and another to set state to install-local in case feature C is installed or reconfigured and the 'legacy-mode' flag is not set. The windows-service component is still shared between feature A, feature B and this child feature of feature C. This seems to work just fine!