How to create a patch that runs a custom action
The 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.
The 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:
- Backup the target package's AIP
- Open it in Advanced Installer
- Go to the Product Details page and increment the version
- After you select another page, you will be prompted for changing the Product Code
- In this dialog, select Keep existing, since the target and upgraded packages must have the same product code
- update the project (add/remove/modify files, registry keys etc.)
- Go to the Custom Actions page and create your custom action
- In the Custom Action Properties page's Execution Stage Condition section, set the Condition field to PATCH
- Save and build the project (the target and upgraded packages must have the same name, for example: "test.msi")
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:
- Open Advanced Installer and, in the "Start Page", select Updates -> Patch
- Save the project
- After configuring the patch information, go to the Images page
- Create the target and upgraded images by using the target and upgraded packages
- 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.