Wix CustomAction [C#] session.Message 在安装过程中未显示
Wix CustomAction [C#] session.Message is not show during the installation
这是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"
});
这是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"
});