views:

549

answers:

1

I have a WiX installer which has 3 Projects. 2 Creates Merge Moduels, 1 Creates the installer. The code in the mergemodules should only be executed if the corresponding feature is selected. Is there any chance to get this to work with custom actions?

From my experience the custom actions are always called - wether or not a certain feature is selected...

Code in the Podoct:

<Feature Id="Complete" Title="SDK Setup" Description="Installs the sdk" Display="expand" Level="1" ConfigurableDirectory="INSTALLLOCATION">
  <Feature Id="SDK" Title ="SDK" Description="" Level ="1">

....

In the Merge Module I call some custom actions, e.g.:

<CustomAction Id='CustomAction' BinaryKey='CaDll' DllEntry='CaEntry' Execute='deferred' />
<CustomAction Id="CustomAction.SetProperty" Return="check" Property="CustomAction" Value='test' Execute='immediate' />

<InstallExecuteSequence>
  <Custom Action='CustomAction.SetProperty' After='CostFinalize'>(NOT Installed) AND (NOT UPGRADINGPRODUCTCODE) </Custom>
  <Custom Action='CustomAction' After='InstallFiles'>(NOT Installed) AND (NOT UPGRADINGPRODUCTCODE) </Custom>
+1  A: 

Custom actions in general are not tied to components or features. From one perspective this is because they should be written in a data-driven fashion: inspect the install and action states of all components in your code to build up a list of actions to take.

But when actions don't make sense that way (even with the help of a custom database table), you can always tie them to the action state of the feature or component by their condition. See Conditional Statement Syntax for "Access Prefixes" or "Feature and Component State Values", and in particular the examples near the bottom: &MyFeature=3 is true when MyFeature is being installed.

Michael Urman