How to create a patch that runs a custom action

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

Sometimes, a patch must perform some actions which are not supported by Windows Installer. In this case, the best solution is to use a custom action that has the execution condition set to PATCH.

Create the target package

A patch is basically the difference between the target and upgraded packages. Therefore, the first step in creating a patch is obtaining the target package. This can be done by creating and configuring a new project.

NoteThe custom action which runs during the patch should not be included in the target package. However, if there is no other solution, the patch will allow the custom action in the target package.

Create the upgraded package

This can be done by following these steps:

  1. Backup the target package's AIP
  2. Open it in Advanced Installer
  3. Go to the Product Details page and increment the version
  4. After you select another page, you will be prompted for changing the Product Code
  5. In this dialog, select Keep existing, since the target and upgraded packages must have the same product code
  6. update the project (add/remove/modify files, registry keys etc.)
  7. Go to the Custom Actions page and create your custom action
  8. In the Custom Action Properties page's Execution Stage Condition section, set the Condition field to PATCH
  9. Save and build the project (the target and upgraded packages must have the same name, for example: "test.msi")

Warning!When increasing the project's version, make sure you do not modify the version's first field. Otherwise, the patch creation process will fail.

Create the patch

A patch can be created by using a "Patch" project:

  1. Open Advanced Installer and, in the "Start Page", select Updates -> Patch
  2. Save the project
  3. After configuring the patch information, go to the Images page
  4. Create the target and upgraded images by using the target and upgraded packages
  5. Build the project

Since the custom action is included in the Upgraded package and it has the condition PATCH, it is automatically included in the patch. Also, its condition will tell Windows Installer to run it when the patch is applied.