MSI InstallFinalize ARP 移除条件

MSI InstallFinalize ARP removal condition

我正在尝试配置 WiX 以构建安装程序,以便我可以通过命令行提供的属性激活功能并将它们迁移到下一个升级。

尝试使用我的 WiX 安装程序进行主要升级时,升级不会从 ARP-Menü 中删除以前的版本。其他 Feature/Component 似乎在重新安装之前被删除(日志列出了它们)。仅当我通过命令行提供的 属性 在先前版本中激活功能时才会出现此问题。

v1 的 ARP 条目被删除:

msiexec /L*v install.log /i installerv1.msi
msiexec /L*v install.log /i installerv2.msi

v1 的 ARP 条目未被删除:

msiexec /L*v install.log /i installerv1.msi EXTRAFEATURE=true
msiexec /L*v install.log /i installerv2.msi EXTRAFEATURE=true

或者

msiexec /L*v install.log /i installerv1.msi EXTRAFEATURE=true
msiexec /L*v install.log /i installerv2.msi

(v1和v2的ProductCode、PackageCode、Product Version不同,UpgradeCode相同)

简化的 WiX 配置:

<Product Id="$(var.CPACK_WIX_PRODUCT_GUID)"
    Name="$(var.CPACK_PACKAGE_NAME)"
    Language="1031"
    Version="$(var.CPACK_PACKAGE_VERSION)"
    Manufacturer="$(var.CPACK_PACKAGE_VENDOR)"
    UpgradeCode="$(var.CPACK_WIX_UPGRADE_GUID)">
    
    <Package InstallerVersion="301"
        InstallScope="perMachine"
        Compressed="yes"
        Description="$(var.CPACK_PACKAGE_NAME)"
        Keywords="!(loc.PackageKeywords)"
        Comments="!(loc.PackageComments)"/>

    <MajorUpgrade
        Schedule="afterInstallValidate"
        AllowSameVersionUpgrades="yes"
        DowngradeErrorMessage="!(loc.DowngradeErrorMessage)"/>

    <FeatureRef Id="ProductFeature"/>
    <FeatureRef Id="ExtraFeature"/>

    <Property Id="EXTRAFEATURE" Secure="yes"/>
    <Feature Id="ExtraFeature" Level="0">
        <Condition Level="1">EXTRAFEATURE</Condition>
        <ComponentRef Id="ExtraFeature"/>
    </Feature>
    
    ...
</Product>

查看日志我只看到一个区别:InstallInitialize 步骤不会触发脚本的生成以删除 ARP 条目。

工作示例:

MSI (s) (14:10) [10:24:20:422]: Doing action: InstallInitialize
Aktion 10:24:20: InstallInitialize. 
Aktion gestartet um 10:24:20: InstallInitialize.
MSI (s) (14:10) [10:24:20:423]: Machine policy value 'AlwaysInstallElevated' is 0
MSI (s) (14:10) [10:24:20:423]: User policy value 'AlwaysInstallElevated' is 0
Aktion 10:24:20: GenerateScript. Für folgende Aktion werden Skriptvorgänge generiert:
GenerateScript: InstallInitialize
MSI (s) (14:10) [10:24:20:429]: PROPERTY CHANGE: Deleting ProductToBeRegistered property. Its current value is '1'.
MSI (s) (14:10) [10:24:20:430]: Note: 1: 2205 2:  3: Class 
MSI (s) (14:10) [10:24:20:430]: Note: 1: 2228 2:  3: Class 4: SELECT `CLSID` FROM `Class` WHERE `Icon_`=? AND `Class`.`Attributes`=1 
MSI (s) (14:10) [10:24:20:430]: Note: 1: 2205 2:  3: Class 
MSI (s) (14:10) [10:24:20:430]: Note: 1: 2228 2:  3: Class 4: SELECT `Component`,`CLSID` FROM `Component`,`Class` WHERE `Component`=`Component_` AND `Icon_`=? AND  (`Component`.`Installed` <> 0 AND `Component`.`Action` <> 0) 
MSI (s) (14:10) [10:24:20:430]: Note: 1: 2205 2:  3: Extension 
MSI (s) (14:10) [10:24:20:430]: Note: 1: 2228 2:  3: Extension 4: SELECT `Component`,`Extension` FROM `Component`,`Extension`,`ProgId` WHERE `Component`.`Component`=`Extension`.`Component_` AND `ProgId`.`ProgId`=`Extension`.`ProgId_` AND `ProgId`.`Icon_`=? AND  (`Component`.`Installed` <> 0 AND `Component`.`Action` <> 0) 
MSI (s) (14:10) [10:24:20:430]: 'ProductIcon.ico' icon will be removed.
Aktion beendet um 10:24:20: InstallInitialize. Rückgabewert 1.

无效示例:

MSI (s) (74:94) [09:50:04:656]: Doing action: InstallInitialize
Aktion 09:50:04: InstallInitialize. 
Aktion gestartet um 09:50:04: InstallInitialize.
MSI (s) (74:94) [09:50:04:658]: Machine policy value 'AlwaysInstallElevated' is 0
MSI (s) (74:94) [09:50:04:658]: User policy value 'AlwaysInstallElevated' is 0
Aktion beendet um 09:50:04: InstallInitialize. Rückgabewert 1.

在 InstallFinalize (https://docs.microsoft.com/en-us/windows/win32/msi/installfinalize-action) 的文档中,我找到了以下描述:

If it is detected that the product is marked for complete removal, operations are automatically added to the script to remove the Add/Remove Programs in the Control Panel information for the product, to unregister and unpublish the product, and to remove the cached local database from %WINDOWS%, if it exists.

我找不到任何关于 ARP 条目被删除时的情况的文档。为什么添加该功能会阻止触发 ARP 删除?

该功能已被禁用,因此不会被删除。

http://www.joyofsetup.com/2008/05/16/make-sure-features-are-always-enabled-so-they-can-be-removed/