drg*_*grd 6 c# custom-action wix
这是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" />
Run Code Online (Sandbox Code Playgroud)
这是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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在安装过程中不显示消息;
那是因为您使用参数InstallMessage.Info调用session.Message.这导致文本不会显示给用户.可以在日志文件中找到该消息.此行为是设计使然.
要归档目标,请将第一个参数更改为 InstallMessage.Warning或 InstallMessage.Error
session.Message(InstallMessage.Warning, new Record
{
FormatString = "Product updated. To upgrade Project execute initHeating.ps1"
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2716 次 |
| 最近记录: |