当前位置:首页 > 操作系统 > MacOs

Wix CustomAction [C#] session.Message在安装期间未显示

这是WIX脚本片段

<code><InstallExecuteSequence>
    <Custom Action="Warning" After="InstallFinalize">NOT INSTALLED</Custom>
</InstallExecuteSequence>
<CustomAction Id="Warning" BinaryKey="ExtendedActions" DllEntry="WarningAboutUpgrade" Execute="immediate" Return="check"/>
<Binary Id="ExtendedActions" SourceFile="$(var.ExtendedActions.TargetDir)$(var.ExtendedActions.TargetName).CA.dll" />
</code>

这是c#自定义操作代码

<code>using Microsoft.Deployment.WindowsInstaller;

namespace ExtendedActions
{
    public class CustomActions
    {
        [CustomAction]
        public static ActionResult WarningAboutUpgrade(Session session)
        {
            session.Log($"Begin CustomAction WarningAboutUpgrade");
            session.Message(InstallMessage.Info, new Record { FormatString = "Product updated. To upgrade Project execute initHeating.ps1 }" });
            return ActionResult.Success;
        }
    }
}
</code>

在安装过程中不显示消息;

解决方法:

那是因为您使用参数InstallMessage.Info调用session.Message.这导致文本不会显示给用户.可以在日志文件中找到该消息.此行为是设计使然.

要归档目标,请将第一个参数更改为InstallMessage.Warning或InstallMessage.Error

<code>session.Message(InstallMessage.Warning, new Record 
{ 
  FormatString = "Product updated. To upgrade Project execute initHeating.ps1" 
});
</code>

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐