You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WiX v4引导程序安装完成后进程无法终止问题求助

WiX v4托管Bootstrapper Application进程无法正常终止问题

问题概述

使用WiX v4开发托管Bootstrapper Application(BA),程序包含多个前置依赖的可再发行组件。安装完成且所有组件均成功安装,但频繁出现UI关闭并调用Engine.Quit(0)后,仍有3个引导程序进程无法终止的情况。可再发行组件安装程序均成功退出且日志无异常,推测问题出在自定义BA中。

Bundle可再发行组件配置

<ExePackage 
    bal:PrereqPackage="yes" 
    Id="NetFramework48" 
    PerMachine="yes" 
    DetectCondition="NETFRAMEWORK45 &gt;= 528040" 
    Vital="yes" 
    Permanent="yes" 
    Protocol="netfx4" 
    LogPathVariable="NetFxInstallLog" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\ndp48-x86-x64-allos-enu.exe" 
    Name="redist\ndp48-x86-x64-allos-enu.exe" 
    InstallArguments="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFxInstallLog].html&quot;" 
    RepairArguments="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFxInstallLog].html&quot;" 
    UninstallArguments="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFxInstallLog].html&quot;" />

<ExePackage 
    Id="DotNET6DesktopRuntimeX86" 
    PerMachine="yes" 
    DetectCondition="DotNET6DesktopRuntimex86Installed" 
    Vital="yes" 
    Permanent="yes" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\DotNET6\windowsdesktop-runtime-6.0.11-win-x86.exe" 
    Name="redist\windowsdesktop-runtime-6.0.11-win-x86.exe" 
    InstallArguments="/install /quiet /norestart" 
    RepairArguments="/repair /quiet /norestart" 
    UninstallArguments="/uninstall /quiet /norestart">
    <ExitCode Behavior="success" Value="0" />
    <!-- Error Code 0x666 or 1638 means a newer version was detected -->
    <ExitCode Behavior="success" Value="1638" />
</ExePackage>

<ExePackage 
    Id="DotNET6DesktopRuntimeX64" 
    PerMachine="yes" 
    DetectCondition="DotNET6DesktopRuntimex64Installed" 
    Vital="yes" Permanent="yes" Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\DotNET6\windowsdesktop-runtime-6.0.11-win-x64.exe" 
    Name="redist\windowsdesktop-runtime-6.0.11-win-x64.exe" 
    InstallArguments="/install /quiet /norestart" 
    RepairArguments="/repair /quiet /norestart" 
    UninstallArguments="/uninstall /quiet /norestart">
    <ExitCode Behavior="success" Value="0" />
    <!-- Error Code 0x666 or 1638 means a newer version was detected -->
    <ExitCode Behavior="success" Value="1638" />
</ExePackage>

<ExePackage 
    Id="DotNET6AspCoreRuntimeX86" 
    PerMachine="yes" 
    DetectCondition="DotNET6ASPCoreRuntimex86Installed" 
    Vital="yes" 
    Permanent="yes" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\DotNET6\aspnetcore-runtime-6.0.11-win-x86.exe" 
    Name="redist\aspnetcore-runtime-6.0.11-win-x86.exe" 
    InstallArguments="/install /quiet /norestart" 
    RepairArguments="/repair /quiet /norestart" 
    UninstallArguments="/uninstall /quiet /norestart" />

<ExePackage
    Id="DotNET8DesktopRuntimeX86"
    InstallArguments="/install /quiet /norestart"
    RepairArguments="/repair /quiet /norestart"
    UninstallArguments="/uninstall /quiet /norestart"
    PerMachine="yes"
    DetectCondition="DotNET8DesktopRuntimex86Installed"
    Vital="yes"
    Permanent="yes"
    Compressed="no"
    SourceFile="$(var.SolutionDir)Resources\Redistributables\DotNET8\windowsdesktop-runtime-8.0.7-win-x86.exe"
    Name="redist\windowsdesktop-runtime-8.0.7-win-x86.exe">
    <ExitCode Behavior="success" Value="0"/>
    <!-- Error Code 0x666 or 1638 means a newer version was detected -->
    <ExitCode Behavior="success" Value="1638"/>
</ExePackage>

<ExePackage
    Id="DotNET8DesktopRuntimeX64"
    InstallArguments="/install /quiet /norestart"
    RepairArguments="/repair /quiet /norestart"
    UninstallArguments="/uninstall /quiet /norestart"
    PerMachine="yes"
    DetectCondition="DotNET8DesktopRuntimex64Installed"
    Vital="yes"
    Permanent="yes"
    Compressed="no"
    SourceFile="$(var.SolutionDir)Resources\Redistributables\DotNET8\windowsdesktop-runtime-8.0.7-win-x64.exe"
    Name="redist\windowsdesktop-runtime-8.0.7-win-x64.exe">
    <ExitCode Behavior="success" Value="0"/>
    <!-- Error Code 0x666 or 1638 means a newer version was detected -->
    <ExitCode Behavior="success" Value="1638"/>
</ExePackage>

<ExePackage
    Id="DotNET8AspCoreRuntimeX86"
    InstallArguments="/install /quiet /norestart"
    RepairArguments="/repair /quiet /norestart"
    UninstallArguments="/uninstall /quiet /norestart"
    PerMachine="yes"
    DetectCondition="DotNET8ASPCoreRuntimex86Installed"
    Vital="yes"
    Permanent="yes"
    Compressed="no"
    SourceFile="$(var.SolutionDir)Resources\Redistributables\DotNET8\aspnetcore-runtime-8.0.7-win-x86.exe"
    Name="redist\aspnetcore-runtime-8.0.7-win-x86.exe"/>

<ExePackage 
    Id="VisualCPlusPlus14Runtime" 
    PerMachine="yes" 
    DetectCondition="VC14RuntimeInstalled &gt; v0.0.0.0" 
    Vital="yes" 
    Permanent="yes" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\Visual C++\VC++2015-2022_x86.exe" 
    Name="redist\VC++2015-2022_x86.exe" 
    InstallArguments="/install /quiet /norestart" 
    RepairArguments="/repair /quiet /norestart" 
    UninstallArguments="/uninstall /quiet /norestart" />

<ExePackage 
    Id="DirectX9C" 
    PerMachine="yes" 
    DetectCondition="DirectX9cInstalled" 
    Vital="yes" 
    Permanent="yes" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\Directx90c\DXSETUP.exe" 
    Name="redist\Directx90c\DXSETUP.exe" 
    InstallArguments="/silent">
    <PayloadGroupRef Id="DirectX9cPayloadGroup" />
</ExePackage>

<ExePackage 
    Id="MicrosoftAccess2010DatabaseEngine" 
    PerMachine="yes" 
    DetectCondition="MSAccess2010DbEngineInstalled" 
    Vital="yes" 
    Permanent="yes" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\AccessDatabaseEngine.exe" 
    Name="redist\AccessDatabaseEngine.exe" 
    InstallArguments="/quiet /norestart" />

<MsiPackage 
    Id="Powershell" 
    InstallCondition="NOT PowershellInstalled" 
    Vital="yes" 
    Permanent="yes" 
    Compressed="no" 
    SourceFile="$(var.SolutionDir)Resources\Redistributables\Powershell\PowerShell-7.3.11-win-x86.msi" 
    Name="redist\PowerShell-7.3.11-win-x86.msi" />

BA类代码

using System.Windows.Threading;
using WixToolset.Mba.Core;

namespace Bootstrapper
{
    /// <summary>
    /// The custom bootstrapper application.
    /// </summary>
    public class CustomBA : BootstrapperApplication, ICustomBA
    {
#nullable enable

        public CustomBA(IEngine engine, IBootstrapperCommand command) : base(engine)
        {
            Engine = engine;
            Command = command;
        }

        /// <inheritdoc/>
        public IEngine Engine { get; set; }

        /// <inheritdoc/>
        public IBootstrapperCommand Command { get; set; }

        /// <summary>
        /// The global dispatcher.
        /// </summary>
        static public Dispatcher? BootstrapperDispatcher { get; private set; }

        /// <summary>
        /// The entry point for the custom UI.
        /// </summary>
        protected override void Run()
        {

            this.Engine.Log(LogLevel.Standard, "Launching custom bootstrapper UX");
            BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

            MainWindowViewModel viewModel = new MainWindowViewModel(this);

            MainWindow view = new MainWindow();
            view.DataContext = viewModel;
            view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();

            if (!viewModel.silent)
            {
                view.Show();
            }

            Dispatcher.Run();

            this.Engine.Quit(0);

        }
    }
}

日志信息

当前bundle日志结尾内容:

[098C:18D8][2024-07-31T13:40:42]i399: Apply complete, result: 0x0, restart: None, ba requested restart:  No
[098C:0B88][2024-07-31T13:45:23]i000: Dispatch complete, quitting engine. 
[098C:18D8][2024-07-31T13:45:23]i500: Shutting down, exit code: 0x0

预期应出现但未出现的日志行:

Cleanup begin.
Cleanup not required due to running Apply.
Cleanup complete, result: 0x0
All the variable ending values blah blah
Exit code: 0x0, restarting: No

排查情况

  • 通常(非总是)手动预先安装.NET Desktop Runtime后,进程会按预期终止并执行清理操作
  • 问题发生在全新纯净系统环境,无待重启项或文件移动操作,BA无明显异常,事件查看器无相关信息
  • 使用Process.GetCurrentProcess().Kill()强制终止虽可行,但会跳过清理和关闭事件,并非合理方案
  • 相同逻辑在WiX v3中无此问题,推测是升级到v4时的配置错误,或v4行为变更(如新增异步逻辑)导致

诉求

恳请提供帮助或相关建议,可按需提供更多日志或代码信息。

内容的提问来源于stack exchange,提问作者mcross5129

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 22:30:56