Uninstall a component during minor upgrade

It is bound to happen. You will have a developer come up to you one day and say, "Remember the DLL file that we shipped in the previous release, we have consolidated its functionality into the core library. We need to remove that library in the latest release." You as a Windows Installer developer would then be frustrated after finding out that you cannot remove components during a minor upgrade and you will have to manage with all the ugliness of a major upgrade.  I will write about the ugliness of a major upgrade in some other blog.

So if you really have to remove the DLL, you need not have to go through the trouble of major upgrade. We can actually uninstall components during a minor upgrade. But the catch is that you should not remove the component from the existing MSI. My colleague Kajal Biswas calls this process as "Puncturing the component". Let me detail the process of puncturing the component.

  1. Consider the component abc.dll which has to be removed. 
  2. Collect the Registry, CLSID and the COM information if you have dynamically acquired them, you will have to fill them in manually later. This is usually the reason why I do not use COM Extract at Build. I usually use 'Extract COM Information' feature of InstallShield DevStudio. This would ensure that I can find out the exact registry entries and COM Settings.  If you had used the WiX Toolset, it is pretty straight forward. You will just have to go to the next step and you can ignore this completely.
  3. Replace abc.dll file with a zero byte file with the same name.
  4. Set the transitive bit of the component. If you are using InstallShield DevStudio, simply set the 'Reevaluate Condition' field in the component property to 'Yes'. 
  5. Replace any existing condition on the component with a condition that evaluates to false. As a habit, I and my colleagues enter the paradoxical '1=0' as the component condition. You can also enter something meaningful like 'GoToHell=666' or something like that.

During a minor upgrade, if the feature associated with the component is reinstalled, the trasitive bit with also force the state of the component to be reevaluated. And since the component is present and the condition is false, the component will be uninstalled during a minor upgrade. It is hack. But it works.

This article is part of the GWB Archives. Original Author: Vagmi Mudumbai

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.