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 Patch, 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 Condition section, set the Expression 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.