启动条件,自定义操作和属性
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了启动条件,自定义操作和属性相关的知识,希望对你有一定的参考价值。
我有这个问题与wix安装程序没有安装我们的应用程序IISversion> = 10。它适用于IISVersion <10。
我在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;
}
}
它没有条件。条件之前执行
功能检查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
以上是关于启动条件,自定义操作和属性的主要内容,如果未能解决你的问题,请参考以下文章
VSCode自定义代码片段15——git命令操作一个完整流程