从每台机器更改为每用户安装后,WiX 升级不起作用。如何卸载旧版本?

WiX upgrade doesn't work after changing from per machine to per user installation. How can I uninstall the old version?

WiX 工具集版本:3.11.2.4516

要从每台机器安装切换到每用户安装,我更改了我的 WiX 配置:

<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="1.0.0.1"
  Manufacturer="$(var.CompanyName)" UpgradeCode="eec853e6-9345-4be0-908f-958f212c6f30">

  <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" />

  <MajorUpgrade Schedule="afterInstallInitialize"
    DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed" />

为此(删除Package/@InstallScopePackage/@InstallPrivileges):

<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="2.0.0.0"
  Manufacturer="$(var.CompanyName)" UpgradeCode="eec853e6-9345-4be0-908f-958f212c6f30">

  <Package InstallerVersion="200" Compressed="yes" />

  <MajorUpgrade Schedule="afterInstallInitialize"
    DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed" />

现在该产品是按用户安装的,而不是按机器安装的。但是 <MajorUpgrade> 不再起作用了。我还尝试将 Product/@UpgradeCode 更改为新的 GUID,并将以下内容添加到我的 WiX 配置(在 <MajorUpgrade> 元素下方):

<Upgrade Id="eec853e6-9345-4be0-908f-958f212c6f30">
  <UpgradeVersion OnlyDetect="no" Property="OLD_SERVICE_INSTALLER_FOUND" Minimum="0.0.0.0" />
</Upgrade>

但这也不管用。

如果我从按机器安装切换到按用户安装,如何卸载旧版本的软件?

你卡住了。这是 windows 安装程序限制。

https://docs.microsoft.com/en-us/windows/win32/msi/major-upgrades

Note

If an application is installed in the per-user installation context, any major upgrade to the application must also be performed using the per-user context. If an application is installed in the per-machine installation context, any major upgrade to the application must also be performed using the per-machine context. The Windows Installer will not install major upgrades across installation context.