编程语言
首页 > 编程语言> > Wix CustomAction [C#] session.Message在安装期间未显示

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

作者:互联网

这是WIX脚本片段

<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" />

这是c#自定义操作代码

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

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

解决方法:

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

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

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

标签:c,wix,custom-action
来源: https://codeday.me/bug/20190519/1136287.html