To create Windows Installer packages, WiX is used in a project I work on. And one day I needed to create a patch for an existing install package.
I started searching how it can be done. The first thing that Google found was this instruction. It suited my needs, more or less. Yet I didn’t manage to create the patch following this instruction. I overcame several obstacles, and then I faced another problem on the last step of the process: the tools didn’t see any modifications between the two different installations. Later I found out why the tools see no modifications. It proved that our packages didn’t store the sizes of files.
The instruction I talked above was written for version 2.0 of WiX. However version 3.0 is already used. It took me some time until I found the updated instructions on the WiX site. There are two of them:
- Creating patches using only WiX tools (since version 3.0);
- Using Patch Creation Properties (the way similar to version 2.0).
There was an issue with both ways: either instruction assumed there’s original .wsx file of the install package. I didn’t have one. After trying various approaches, including install package decompilation, I still didn’t manage to create patch. I even downloaded a fresh WiX build, but it didn’t help either.
Then I decided to start it all over and to begin with checking the instruction itself. I created a small package and an updated package. And I managed to create the patch between these two.
When I searched for solutions, I came across a post “Patching something you didn’t build with WiX using WiX”. It describes the procedure of creating patch from .msi files. That’s what I needed. Yet there were no details. The post stated that the command lines are the same as in “Building a Patch using the new Patch Building System – Part 3” post. But the instructions there simply repeat what’s written in the WiX documentation.
I used administrative install and option -ax instead of -xi, as it was described. And torch.exe failed with the same error as in the second comment: torch.exe : error TRCH0001 : The Windows Installer service failed to start. Contact your support personnel.
After I re-read all the comments carefully, I found a hint in the seventh comment: option -xo. This hint helped to create the patch.
This instruction assumes you work in C:\patch.
Perform administrative install:
msiexec /a install.msi /qb TARGET=C:\patch\rtm
Copy the image:
xcopy /i rtm upp
Using Orca, change the package code in the updated install image:
- On the File menu, click Open.
- In the Open dialog, type C:\patch\upp\install.msi and click Open.
- On the View menu, click Summary Information.
- Find Package code field and click New GUID to the right of it. The package code will be updated. Click OK.
- On the File menu, click Save to save the package.
The Orca editor is part of Windows SDK.
- Update the files under C:\patch\upp with the new versions.
Evaluate the differences between the two packages:
torch -p -ax C:\patch\temp -xo rtm\install.msi upp\install.msi -out patch\diff.wixmst
Create patch description file patch.wsx. You can take it from Create your patch authoring in the sample root section of the WiX instructions.
I created my own based on it.
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Patch AllowRemoval="yes" Manufacturer="Organization" DisplayName="Patch name" Description="Patch description" Comments="Patch comment" Classification="Update" Codepage="1251" > <Media Id="5000" Cabinet="ProductP.cab"> <PatchBaseline Id="RTM"/> </Media> </Patch> </Wix>
Mediaelement must be greater than the number of files in the original image; it should also take files from previous patches into account. If you’re authoring a second patch and the previous patch used 5000 as
Idand updated 11 files, then this number must be greater than 5011.
Create the patch itself:
candle patch.wsx light patch.wixobj -out patch\patch.wixmsp pyro patch\patch.wixmsp -out patch\patch.msp -t RTM patch\diff.wixmst
- The patch is ready. It’s time to verify it works as expected. To do it, install the original install package, then install the patch and check the files were really updated.
In my case patch installation wasn’t smooth: the patch needed to update files which were not KeyPath of a Component. I guess no one thought about it when the installation package was created. In order to install the update correctly, property REINSTALLMODE must contain a mode. It was issued as warning by pyro.exe. So one needs to use the following command line:
msiexec /p patch.msp /qb REINSTALL=ALL REINSTALLMODE=omusa
Without /qb option, the full UI with Modify, Repair, Remove buttons is displayed, which is not quite great. I tried to click Modify and then click Next; patch installed successfully in this case. I didn’t try to click other buttons.