Wix,将自定义属性设置为true不起作用

时间:2016-03-17 12:25:56

标签: wix windows-installer installer

Wix片段:我正在设置属性FEATURE_IS_SELECTED

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

然后调用自定义操作:

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

自定义操作:

 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;
    }

调试此操作时,将调用该操作,但if条件不为true。为什么没有设置FEATURE_IS_SELECTED?并且//在这里执行不执行?

1 个答案:

答案 0 :(得分:0)

您的配置自定义操作未标记为&#34;执行&#34;值,所以默认值是立即的。这意味着CustomActionData不参与获取值。但是,您似乎想要更改已安装的文件,因此您需要的唯一更改是将CA标记为延迟执行,以便在实际安装文件后运行,然后您还需要单独的自定义操作来准备CustomActionData ,就像这里:

How to pass CustomActionData to a CustomAction using WiX?

您的排序可能有点可疑 - 您可以在CostFinalize之后随时设置FEATURE_IS_SELECTED并且可以立即进行。在安装文件&#34;之后,配置您的Xml可能会更好。

相关问题