Assemblies may be missing from the GAC or WinSxS cache after an MSI major upgrade

I recently read about an issue that affects Windows Installer products that use major upgrades and also install assemblies to the GAC or the WinSxS component store using the MsiAssembly and MsiAssemblyName tables.  This issue is documented in the Microsoft Knowledge Base article at https://support.microsoft.com/kb/905238.

To summarize the issue, if you build an MSI that installs assemblies and includes major upgrade functionality, and then build a new version of the MSI that invokes a major upgrade, you may see the assemblies removed from the GAC or the WinSxS store after the major upgrade completes.  This happens if you do not change the assembly version for your assemblies and have not scheduled the RemoveExistingProducts action to occur after the InstallFinalize action.

If you are running into this issue with your MSI, you can workaround this issue in one of the following 2 ways:

  1. Increment the assembly version number for each of your assemblies every time you deliver a new MSI that will be installed via a major upgrade
  2. Schedule the RemoveExistingProducts action to occur after the InstallFinalize action in your MSI

If you change the scheduling, you do not necessarily need to increment the assembly version number for each of your assemblies.

One important note here - the sample WiX files for the Q and Z sample applications that ship in the Windows Media Center SDK for Windows Vista are susceptible to this problem.  I have updated the downloadable WiX v3.0 projects for the Q application (that can be downloaded from this location and that is described here) and the Z application (that can be downloaded from this location and that is described here) to address this.  The specific change I made in q.wxs and z.wxs implements the 2nd option listed above by changing this line in each WXS file:

<RemoveExistingProducts After="InstallInitialize" />

To this:

<RemoveExistingProducts After="InstallFinalize" />

If you have the Media Center SDK installed and want to make this fix for the WiX v2.0 files that are installed as part of the SDK, you can make equivalent changes to the versions of q.wxs and z.wxs included there.