Patch Packages in windows Installer

Patch Packages

•    A Windows Installer patch (.msp file) is a file used to deliver updates to Windows Installer applications. The patch is a self-contained package that contains all the information required to update the application. A patch package (.msp file) can be much smaller than the Windows Installer package (.msi file) for the entire updated application.

•    A patch package contains the actual updates to the application and describes which versions of the application can receive the patch. Patches contain at minimum two database transforms. One transform updates the information in the installation database of the application. The other transform adds information that the installer uses for patching files. The installer uses the information provided by the transforms to apply patch files that are stored in the cabinet file stream of the patch package. A patch package does not have a database like an installation package (.msi file.)

•    Patches require that an existing version of the software application be present because (unlike upgrade packages) they do not include a fully functional version of the package or software application. Patch packages achieve smaller file sizes through two methods:

1.    Only files that have changed are evaluated for inclusion in the patch.

2.    Only the actual binary changes between the old file and new file are included in the patch.Special differencing technology is used to generate binary pieces of the files to be patched and to use the pieces to alter older versions of the file during patch application.

•     Patching has the ability to patch multiple previous versions of the target files. For instance, a patch may be able to update versions 1.01, 1.37, and 1.42 to version 1.50.

Some Key Points regarding Patches

1.    Patch does the same job as that of a Transform.
2.    It is applied to one of the already installed Msi.
3.    Extension of a patch file is (.MSP) similar to (.MST) of the Transform.
4.    Patch is Self-Executable. Double-Clicking the patch file (.MSP) will apply the patch on the already installed MSI.
5.    ‘ProductCode’ property decides the MSI on which the patch needs to be applied. So, while creating the patch, it is required not to change the ‘ProductCode’ Property.
6.    The icon of the Patch file (.MSP) is same as that of the Windows Installer file (.MSI).
7.    Multiple Patches can be created for the same base MSI.
8.    Patch requires at least two source MSIs, both in ‘Uncompressed External Files’ format.
9.    It is preferred to take the ‘Admin Image’ of both the MSIs.

Syntax to take the Admin Image of an MSI

Msiexec /a “path of the .MSI file”

Execute this command to get the admin image of the MSI. It will prompt for the destination folder.

    If the media of the .MSI file is in compressed format, Admin Install will convert it into Uncompressed External Files and will be thrown into %temp% folder by default.
    Patch captures the difference between the two MSIs and creates two files within the destination folder. A patch settings file(.pcp) and a self executable patch file(.msp).
    Before patch creation, it is very important to create two copies of the folder having the (.MSI) file in Uncompressed External Files format. Then, make changes within one of the copies. If this is not followed, one may end up making changes to the base MSI because of which the Admin Image may get modified. This will result in two different MSIs with the same Admin Image.

When to use a Patch
Patch is to be used when we need to make some modifications in the package without uninstalling it.

For example. Consider a case where patch needs to be used.

When the Base MSI is already installed on the client’s machine but some modifications are to be done on it. Here, if we create a transform, we need to uninstall the base MSI first and then apply the Transform along with the Installation of the base MSI. This can be avoided by using a patch. Here, we need not uninstall the Base MSI, but rather create a patch and directly install it on the client’s machine. The patch will directly get applied to the base MSI depending on its Product Code Property.

Generating Patches

To generate a patch, a full upgrade package must be built. The Windows Installer patching routines (shipped in the SDK and included in many authoring tools such as wise package studio [Patch Creation]) are run to generate the patches.