【问题标题】:Launch Condition, custom action and property启动条件、自定义操作和属性
【发布时间】:2017-12-17 02:33:24
【问题描述】:

wix 安装程序没有安装我们的应用程序 IISversion >=10。它适用于 IISVersion

我在 github 上找到了这个链接。 https://github.com/wixtoolset/issues/issues/5276 此链接建议添加一个自定义操作,如果 IISRegistryversion >= IISRequiredVersion,则返回 ActionResult.Success。 但我收到以下错误。错误发生在日志中之后 执行操作:LaunchConditions

动作开始时间 12:46:02:LaunchConditions。 未设置变量或未调用自定义操作。 我在自定义操作中有一些日志记录,但即使打开了详细信息,它也没有记录任何内容。

如何确保在评估此条件之前调用了启动条件/自定义操作?谁能推荐一下?

这是 Product.wxs 的样子

<InstallExecuteSequence>
    <Custom Action="CA.DS.CreateScriptDirCommand" Before="InstallFinalize">
        <![CDATA[NOT Installed AND (&Feature.DatabaseServer.Database = 3)]]>
    </Custom>
    <Custom Action="Iis.CheckInstalledVersion.SetProperty" Before="LaunchConditions" >
        <![CDATA[NOT Installed AND &Feature.WebServer.WebServices = 3]]>
    </Custom>
    <Custom Action="Iis.CheckInstalledVersion" After="Iis.CheckInstalledVersion.SetProperty" >
        <![CDATA[NOT Installed AND &Feature.WebServer.WebServices = 3]]>
    </Custom>
</InstallExecuteSequence>
<Condition Message="This application requires IIS [Iis.RequiredVersion] or higher. Please run this installer again on a server with the correct IIS version.">
    <![CDATA[Iis.IsRequiredVersion > 0]]>
</Condition>


<Fragment>
    <CustomAction Id='Iis.CheckInstalledVersion.SetProperty' Property='Iis.CheckInstalledVersion' Execute='immediate' Value='' />
    <!--Note: Changed "Execute" from "deferred" to "immediate", to avoid error "LGHT0204: ICE77: Iis.CheckInstalledVersion is a in-script custom action. It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table"-->
    <!--Note: Changed "Impersonate" from "no" to "yes", to avoid warning "LGHT1076: ICE68: Even though custom action 'Iis.CheckInstalledVersion' is marked to be elevated (with attribute msidbCustomActionTypeNoImpersonate), it will not be run with elevated privileges because it's not deferred (with attribute msidbCustomActionTypeInScript)"-->
    <CustomAction Id='Iis.CheckInstalledVersion' BinaryKey='B.WixCA' DllEntry='CheckInstalledIISVersion' Execute='immediate' Return='check' Impersonate='yes' />
    <Component 
</Component>
</Fragment>


    [CustomAction]
    public static ActionResult CheckInstalledIISVersion(Session session)
    {
        try
        {
            session.Log("* Starting to check installed IIS version");
            const int IisRequiredVersion = 7;

            string IISMajorVersionFromRegistry = session["IISMAJORVERSION"];
            session.Log(string.Format("*!*! DEBUG; CheckInstalledIisVersion; IIS major version: {0}", IISMajorVersionFromRegistry));
            string iisMajorVersionNumeric = IISMajorVersionFromRegistry.Replace("#", string.Empty);
            int iisMajorVersion = int.Parse(iisMajorVersionNumeric, CultureInfo.InvariantCulture);

            bool isRequiredVersion = iisMajorVersion >= IisRequiredVersion;

            // Setting the required version as a custom property, so that it can be used in the condition message
            session["IIs.RequiredVersion"] = IisRequiredVersion.ToString(CultureInfo.InvariantCulture);
            // Setting the results of the check as "bool"
            session["Iis.IsRequiredVersion"] = isRequiredVersion ? "1" : "0";

            return ActionResult.Success;
        }
        catch (Exception ex)
        {
            session.Log(string.Format("CheckInstalledIisVersion; Error occured SC: {0}", ex.Message));
            return ActionResult.Failure;
        }
    }

它可以在没有条件的情况下工作。条件在

之前执行

【问题讨论】:

    标签: wix windows-installer


    【解决方案1】:

    功能检查 Feature.WebServer.WebServices = 3 不起作用,因为在计算成本(并且通常在功能对话框中选择功能)之后才设置“待安装”功能状态。所以没有调用 CA。

    您可能需要重新考虑这一点并在 CostFinalize 之后强制检查 IIS,然后可能会警告 IIS 未安装/运行等。因此,您将无条件搜索 IIS 以设置属性而不使用它作为启动条件。如果 &Feature.WebServer.WebServices = 3 并且 IIS 版本太低,则给出警告。

    请参阅功能操作条件文档和对 CostFinalize 的参考:

    https://msdn.microsoft.com/en-us/library/windows/desktop/aa368012(v=vs.85).aspx

    【讨论】:

    • 有趣!!。谢谢。
    • session["Iis.IsRequiredVersion"] = isRequiredVersion ? “1”:“0”;由于 Iis.IsRequiredVersion 可以是 '1' 或 '0',条件应该是 &Feature.WebServer.WebServices = 3 AND Iis.IsRequiredVersion > '0' 吗?还是应该是 &Feature.WebServer.WebServices = 3 AND Iis.IsRequiredVersion > 0?
    猜你喜欢
    • 1970-01-01
    • 2011-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 2011-11-23
    • 2014-10-14
    相关资源
    最近更新 更多