WiX双安装器驱动升级后卸载失败问题求助
Hmm, let's break down what's happening here—this is a classic case of how Windows Installer's shared component reference counting interacts with DIFX driver handling.
What's Going Wrong
When you mark a component as Shared="yes" with the same GUID across two separate installers, Windows Installer treats it as a shared resource tracked by a reference count. Each installer that installs the component increments this count, and only when the last installer (the one that drops the count to 0) is uninstalled will the component be removed.
Looking at your uninstall log, this line confirms the root cause:
MSI (s) (F0:74) [19:39:55:832]: Component: _Driver_MYDriver.sys_Win8.XXXXXXX_XXXX_4XXXX3_XXXXX_XXXXXXXXXXXX; Installed: Local; Request: Absent; Action: Null; Client State: Local
The Action: Null means Windows Installer isn't removing the component because it still has an active reference from your first installer (INSTALLER1). Since the component stays installed, DIFXAPP skips the driver uninstall step—hence the NoOp_{MYDRIVER_COMPONENT_GUID} flag being set to TRUE in the logs.
Fixes to Resolve the Issue
1. Use WiX MajorUpgrade for Proper Version Replacement
If INSTALLER2 is intended to be an upgrade to INSTALLER1, you need to turn it into a proper upgrade package using WiX's MajorUpgrade element. This will automatically uninstall INSTALLER1 when you install INSTALLER2, resetting the component's reference count to 1. Then, when you uninstall INSTALLER2, the count drops to 0, triggering component removal and DIFX's driver uninstall.
Add this to your INSTALLER2 WiX project (ensure both installers share the same UpgradeCode in their <Product> element):
<MajorUpgrade AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
2. Verify Shared Component Reference Count
To confirm how many products are referencing your driver component, check the Windows Installer registry entries:
- Navigate to
HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components - Locate the subkey matching your component's GUID (
EXXXXXX-XXX-XX) - The values under this key list the Product Codes of all installers using the component. If both INSTALLER1 and INSTALLER2 are present, this confirms the reference count is 2.
3. Adjust Your Shared Component Strategy (If Independent Installers Are Required)
If you truly need two separate, independent installers sharing the driver, uninstalling one won't remove the driver (since the other installer still references it). If this behavior isn't desired:
- Remove
Shared="yes"from the component (note: this risks duplicate driver installations and version conflicts) - Or implement a custom action that checks for other referencing products before uninstalling the driver (this is more complex and error-prone)
4. Double-Check DIFX Configuration
Your difx:Driver element already has DeleteFiles="yes" set correctly, but remember this only activates when Windows Installer actually removes the component. If the component stays installed due to a non-zero reference count, this setting has no effect.
Final Note
The most straightforward and reliable fix is setting up a proper Major Upgrade between your two installers. This ensures the upgrade replaces the old product entirely, and uninstalling the new installer will correctly remove the driver since there's no remaining reference to the shared component.
内容的提问来源于stack exchange,提问作者user3664223

