1

I have a product.msi having some custom action and it has been released.

patch.msp is a patch I made for product.msi.

when I remove this patch from Control panel => Add/Remove Program, custom action which in old package always run. that is not my expectation.

I don't want to run custom action when patch uninstall.

I also googled, but no good way fro released product, I can't change the wxs file to add condition for custom action.

Anyone can help me? Most thanks your help!

Jiang
  • 33
  • 5

1 Answers1

2

A patch features patch-specific properties such as PATCH and MSIPATCHREMOVE. Use these conditions on custom actions to make them run or not run during a patch depending on what is necessary.

Be careful with the conditions on custom actions, they are complicated to get right. Here is a "MSI Conditions Cheat Sheet" to help you. I have not tested these conditions - testing is the only guarantee.

I am throwing in some further patching advice since this is difficult stuff to deal with. Please do read to save yourself trouble. Hate sending people down the wrong track with such a problematic technology:

  • If there are errors in a product's uninstall sequence your fix involves creating a very carefully designed minor upgrade that you can deliver as a patch. This is one of the best uses of a patch.
  • A minor upgrade does not uninstall the existing installation, but rater re-caches a new MSI file to use for maintenance and uninstall operations. Hence you can fix the uninstall before it is run.
  • Create a minor upgrade, test it fully as a regular upgrade install, and then package it as a patch. A patch is merely a distribution / delivery mechanism for an upgrade that works.
  • Don't waste time making a patch before the upgrade is verified. This is a common mistake that wastes a lot of time. In fact if the minor upgrade works, a patch may not be necessary at all. Just use the minor upgrade unless your MSI file is enormously big and you want to deliver a small "hotfix".
  • If you need to include files in your patch, I recommend enabling "include whole files". Otherwise bit-level patching is done, and this is unnecessary complexity (unless your binaries are enormous).
  • Include only what you need in a patch. Add no files or settings that are not required, and you can make a reliable patch. Avoid adding custom actions if at all possible.
  • Be aware that a patch uses the same InstallExecuteSequence as a regular install, but you can condition custom actions differently with patch-specific properties such as PATCH and MSIPATCHREMOVE. Use these conditions on custom actions to make them run or not run during a patch depending on what is necessary.

This "fix uninstall approach" is one of very few scenarios where I find MSI-patching can be successfully used. Otherwise patching is very complicated and error prone. It is also effective for small "hotfixes" to huge products - which obviously is what the whole technology is designed for.

Check Stefan Kruger's installsite.org for more upgrades and patching tips.

Check out this well known wix tutorial for upgrades and patches. And MSDN.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164