启动条件,自定义操作和属性

时间:2017-12-15 18:55:49

标签: wix windows-installer

我有这个问题,wix安装程序没有安装我们的应用程序IISversion> = 10。它适用于IISVersion< 10。

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

动作开始12:46:02:LaunchConditions。 要么未设置变量,要么未调用自定义操作。 我有一些登录自定义操作但它没有记录任何东西,即使详细。

在评估此条件之前,如何确保调用启动条件/自定义操作?有人可以建议吗?

enter image description here

这就是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;
        }
    }

它没有条件。条件在

之前执行

1 个答案:

答案 0 :(得分:1)

功能检查Feature.WebServer.WebServices = 3无法正常工作,因为要安装的功能&#34;&#34;在成本计算之后(通常在要素对话框中选择要素),状态不会设置。所以CA没有被调用。

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

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

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