Add/Remove 程序中的 Wix bootsrapper 多个实例

Wix bootsrapper multiple instance in Add/Remove Programs

我花了几天时间解决了 Add/Remove 程序中许多版本的 boostrapper 的问题。

我尝试了很多方法,使用 DisableRemove、DisableModify、UpgradeCode、ParentName 和 Bundle 属性的版本的不同组合。我正在尝试附加到事件 PlanRelatedBundle 和 DetectRelatedBundle,但我无法在那里设置任何内容。

从 2012 年开始发现这个问题,但不幸的是,引导程序没有针对此问题的明确解决方案。 http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Bootstrapper-Upgrade-Detection-td7580471i20.html

在日志中我可以看到它找到了相关的包

第一个版本 1.0.108.0:

[4364:38F8][2021-05-05T07:58:53]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}, options: 0x7, disable resume: No [4364:38F8][2021-05-05T07:58:54]i000: Caching bundle from: 'C:\Users\M4360~1\AppData\Local\Temp{82501D9E-759F-4960-9F6B-D34CB27DBC5B}.be\ETest.exe' to: 'C:\ProgramData\Package Cache{a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}\ETest.exe' [4364:38F8][2021-05-05T07:58:54]i320: Registering bundle dependency provider: {a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}, version: 1.0.108.0 [4364:38F8][2021-05-05T07:58:54]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}, resume: Active, restart initiated: No, disable resume: No

第二个版本 1.0.109.0:

[0FC0:2F94][2021-05-05T08:16:19]i000: *********** EVENT: PlanRelatedBundle, arg name: PlanRelatedBundleEventArgs - BundleId, value: {a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}. State, value: Absent. Result, value: None. , sender:: BootstrapperStartup

[0FC0:2F94][2021-05-05T08:16:19]i207: Planned related bundle: {a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}, type: Upgrade, default requested: Absent, ba requested: Absent, execute: Uninstall, rollback: Install, dependency: None

[2278:35D8][2021-05-05T08:16:22]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{e0e0d315-c8fc-4f19-acb0-01791a533e15}, options: 0x7, disable resume: No [2278:35D8][2021-05-05T08:16:23]i000: Caching bundle from: 'C:\Users\M4360~1\AppData\Local\Temp{B525729B-76AE-4428-9F13-9DA529F2E455}.be\ETest.exe' to: 'C:\ProgramData\Package Cache{e0e0d315-c8fc-4f19-acb0-01791a533e15}\ETest.exe' [2278:35D8][2021-05-05T08:16:23]i320: Registering bundle dependency provider: {e0e0d315-c8fc-4f19-acb0-01791a533e15}, version: 1.0.109.0 [2278:35D8][2021-05-05T08:16:23]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{e0e0d315-c8fc-4f19-acb0-01791a533e15}, resume: Active, restart initiated: No, disable resume: No

第三个版本 1.0.110.0:

[1C30:06C8][2021-05-05T08:26:14]i000: *********** EVENT: PlanRelatedBundle, arg name: PlanRelatedBundleEventArgs - BundleId, value: {a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}. State, value: Absent. Result, value: None. , sender:: BootstrapperStartup
[1C30:06C8][2021-05-05T08:26:14]i000: *********** EVENT: PlanRelatedBundle, arg name: PlanRelatedBundleEventArgs - BundleId, value: {e0e0d315-c8fc-4f19-acb0-01791a533e15}. State, value: Absent. Result, value: None. , sender:: BootstrapperStartup

[1C30:06C8][2021-05-05T08:26:14]i207: Planned related bundle: {a0118d1b-5688-4e44-a1a9-61c7b7b4d9f0}, type: Upgrade, default requested: Absent, ba requested: Absent, execute: Uninstall, rollback: Install, dependency: None [1C30:06C8][2021-05-05T08:26:14]i207: Planned related bundle: {e0e0d315-c8fc-4f19-acb0-01791a533e15}, type: Upgrade, default requested: Absent, ba requested: Absent, execute: Uninstall, rollback: Install, dependency: None

GUID 正确,但我在日志中看不到任何关于以前版本的更多信息,也看不到它们被卸载。

我尝试将 ParentName 添加到 Bundle,但它导致 Add/Remove 程序中没有显示新版本并且不删除旧版本。

最后我的安装程序安装了 5 个东西,其中 4 个是我的 .msi 需要安装的程序,我不知道这些其他版本是否最终被卸载,只剩下注册表?为什么他们在添加/删除程序中?因为在安装下一版本的 boostrapper 时,它不会占用那么多磁盘 space 因为它的整个大小从 1.3gb 开始大约需要 200 / 300mb,而我的 .msi 有 170mb + 日志。

也许删除 PlanRelatedBundle 中的注册表就足够了?

编辑

我尝试在事件 OnPlanRelatedBundle 中删除注册表,我得出结论,引导程序在升级期间没有删除注册表的权限,会引发错误,RegistryKey key = key32.OpenSubKey (registryKey, true) ;。如果我在卸载 bootstrapper 时附加到进程,权限更高并成功删除旧版本 boostrapper 的寄存器。但是安装程序增加了“Launched elevated engine process”。 exe,运行作为管理员也不会让老版本卸载。

我通过挂钩 OnPlanRelatedBundle 事件并删除旧版本应用程序的注册表解决了这个问题。

但是,这需要 运行 具有管理权限的引导程序。

    private void OnPlanRelatedBundle(object sender, PlanRelatedBundleEventArgs e)
    {
        try
        {
            string registryKey = @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
            RegistryKey key32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
            RegistryKey key = key32.OpenSubKey(registryKey, true);
            if (key != null)
            {
                key.DeleteSubKeyTree(e.BundleId, false);
                key.Close();
            }
        }
        catch (Exception ex)
        {
        }
    }