wix - 在 WiX 中卸载时如何显示对话框或消息框?

标签 wix

我试图在卸载过程中显示一个对话框或消息框(带有是或否按钮)。
我需要从我的对话框中设置一个用户选择的属性(是(真)或否(假))。
此属性很重要,因为如果用户的回答是"is",所有文件都将被删除。
我试图在卸载时显示一个自定义对话框,但没有用。自定义对话框没有给我一个错误。它甚至没有出现在详细日志中。

这是自定义对话框:

<Dialog Id="ClearAllDataDlg" Width="260" Height="85" Title="[Setup] - [ProductName]" NoMinimize="yes">
    <Control Id="No" Type="PushButton" X="132" Y="57" Width="56" Height="17" Default="yes" Cancel="yes" Text="[ButtonText_No]">
      <Publish Property="CLEARALLDATA" Value="0" />
      <Publish Event="EndDialog" Value="Return">1</Publish>
    </Control>
    <Control Id="Yes" Type="PushButton" X="72" Y="57" Width="56" Height="17" Text="[ButtonText_Yes]">
      <Publish Property="CLEARALLDATA" Value="1" />
      <Publish Event="EndDialog" Value="Exit">1</Publish>
    </Control>
    <Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="30">
      <Text>Do yo want to clear all data including your settings?</Text>
    </Control>
    <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24" ToolTip="Information icon" FixedSize="yes" IconSize="32" Text="[InfoIcon]" />
  </Dialog>

和 InstallUISequence:
<Show Dialog="ClearAllDataDlg" Before="CostFinalize">REMOVE ~= "ALL"</Show>

我在序列中尝试 After="MigrateFeatureStates"但这也不起作用。
在另一个问题中有人问 Stopping display of custom dialog boxes in WiX uninstall这很有趣,因为所有其他问题都试图做相反的事情。
我不想在自定义操作中执行此操作,因为我想阻止卸载进度并等待用户的回答。
有什么办法可以做到这一点吗?
任何帮助,将不胜感激。谢谢!

最佳答案

我在我们生产的 SDK 安装中正是这样做的。这个想法是,如果用户在 SDK 安装位置内进行了任何实际开发,所有内容都会被删除,我们希望确保他们保存他们真正需要的任何内容。

我没有为此警告框创建新对话框,因为消息框是所有 Windows 产品中定义和使用非常明确的概念。

在产品中,我添加了一个自定义操作计划 之前 任何事情都会发生。

<CustomAction Id='CA_UninstallWarning' BinaryKey='SDKCustomActionsDLL' DllEntry='UninstallWarning' Execute='immediate' Return='check' />

<InstallExecuteSequence>
    <Custom Action='CA_UninstallWarning' Before='FindRelatedProducts'>NOT UPGRADINGPRODUCTCODE AND REMOVE~="ALL"</Custom>
    ...
</InstallExecuteSequence>

在我的自定义操作中,我有
[CustomAction]
public static ActionResult UninstallWarning(Session session)
{
    session.Log("Begin UninstallWarning.");

    Record record = new Record();
    record.FormatString = session["WarningText"];

    MessageResult msgRes = session.Message(InstallMessage.Warning | (InstallMessage)System.Windows.Forms.MessageBoxButtons.OKCancel, record);

    session.Log("End UninstallWarning.");

    if (msgRes == MessageResult.OK)
    {
        return ActionResult.Success;
    }

    return ActionResult.Failure;
}

在您的情况下,您可以使用 messageboxbuttons.YesNo 而不是 OKCancel

return="check"在您的自定义操作中,如果您从自定义操作返回 ActionResult.Failure,安装将停止。

我确实从 wix bootstrap 启动了这个卸载,但行为应该是相同的。

关于wix - 在 WiX 中卸载时如何显示对话框或消息框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40926730/

相关文章:

permissions - CustomAction 以管理员身份运行

visual-studio - 如何在 WiX 安装程序项目中引用自定义 WiX 扩展项目?

wix - WiX中TARGETDIR和INSTALLDIR的用法是什么?

xml - WiX Unresolved 引用错误

c# - 包含许多子文件夹和文件的 WiX 安装程序

wpf - 从 WIX 安装程序 : Fail on STAThread issue 启动使用 WPF 编写的 CustomAction UI

c# - Wix:托管 BA 命令行无效

sql - 有用于SQL连接的WiX 3.5兼容扩展对话框吗?

c# - SQLite 的相对路径不适用于 WIX 工具集

wix - Windows Installer 不安装功能并且不报告错误。 (请求: Null)