0

Wix fragment: I am setting a property FEATURE_IS_SELECTED

<SetProperty Id="FEATURE_IS_SELECTED" Value="1" After="InstallFiles"  Sequence="execute"><![CDATA[&MyFeature=3]]></SetProperty>

then calling a Custom Action:

<Custom Action="ConfigureMyXml" Before="InstallFinalize">NOT Installed OR MaintenanceMode="Modify"</Custom>

Custom action:

 public const string IsFeatureSelected = "FEATURE_IS_SELECTED";

 [CustomAction]  
    public static ActionResult ConfigureMyXml(Session session)
    {
        string value;
        MessageBox.Show("I will check if value is set");
        if (session.CustomActionData.TryGetValue(IsFeatureSelected, out value))
        {
            //do sth here
        }

        return ActionResult.Success;
    }

When debugging this, the action is called, but the if condition is not true. Why the FEATURE_IS_SELECTED is not set ? and //do sth here does not execute?

1 Answers1

0

Your configure custom action is not marked with an "execute" value, so the default value is immediate. That means CustomActionData isn't involved in getting the value. However, it looks like you want to alter an installed file, so the only change you need is to mark the CA as execute deferred so it runs after the files are actually installed, and then you will also need a separate custom action to prepare CustomActionData, as here:

How to pass CustomActionData to a CustomAction using WiX?

Your sequencing may be a little suspect - you can set FEATURE_IS_SELECTED anytime after CostFinalize and it can be immediate. Configuring your Xml might be better "after install files".

Community
  • 1
  • 1
PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Custom action doesnt need to be deferred to run after files are installed. He just need to set After="InstallFinalize" – Chris Tanev Mar 18 '16 at 10:16