Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a MSI patch (.msp) by hand?

Our team has recently been considering pushing out a minor registry fix to users to modify one particular problematic key. Pretty straightforward stuff, just needed to update 1 key/value inside the registry.

So at the moment, we are using Wix to build .msi installers for the product. While looking into Wix's support for generating .msp patch files, it seems that the only way to create an .msp is a somewhat overcomplicated multi-step process to:

  1. Get a copy of the original MSI, and compile a new copy of the fixed MSI
  2. Write a new Wix file that points to both installers
  3. Compile the Wix file into a .wixobj with Candle to a .psp
  4. Run Torch/Pyro over before/after snapshots of the original installers and the .psp, or alternatively using MsiMsp.exe

Now my question is, can't I simply describe the registry change into a Wix file and directly compile it into the .msp, without step 1 and 4 - which is a huge amount of effort for just a simple change?

like image 524
Jerry Chong Avatar asked Mar 19 '10 02:03

Jerry Chong


People also ask

How do I create an MSP file using InstallShield?

To create a new QuickPatch project in InstallShield, you can pull down the File menu, select New, and then select QuickPatch Project, entering the name of the InstallShield project (ISM) file to create.

How do I create a Windows patch file?

Creating a patch using WinMerge Use File -> Open... to open the two versions for comparison. This will give you a nice view of what you have changed. Then do Tools -> Generate patch .... In the dialogue box, make sure you select Style: Unified in the Format box.

How do I unpack an MSP file?

A Microsoft Patch (MSP) file is usually contained in a Service Pack executable that you download from Revit Support website. To extract the MSP file from the executable, run the patch program from the Windows command prompt using the /e switch. Pay particular attention to the location where the files are extracted.


2 Answers

No. A patch is the delta of two installable images. To generate the delta, even if the difference is very small, you will need both images.

like image 188
Ed. Avatar answered Sep 23 '22 10:09

Ed.


Yes, there is another way, even though you may consider it equally complicated:

  1. Create an admin install of your "base version" using msiexec /qn /a <msi-file> TARGETDIR=<absolute-path-of-existing-directory> (if you run this from a make file or other script, use start /wait in front of the command), say into %BASEDIR%
  2. repeat the above, but into %UPDDIR%
  3. Now that you have the installation unpacked inside %UPDDIR%, make your changes to the .msi file that will be in the root of that folder ... you should also preferably change the version number ...
    • If you exchange files, make sure to update the hash table (MsiFileHash) or the File table for files with version information.
    • If you change merely some registry value, you should be fine without any of that ...
  4. Now prepare a .pcp (Patch Creation Properties) file to point one row in the TargetImages table to the .msi in %BASEDIR% and one row in UpgradedImages to the .msi in %UPDIR%
  5. Invoke msimsp.exe <pcp-file> -p <absolute-path-to-desired-patch-file>

Voila, you're done.

Now whether this is worth it depends solely on you.

It's how I am doing it with the help of some scripts that run SQL queries on the MSI databases in order to query values or update them as needed. This works perfectly well and has been put into a GNU make file to build a whole bunch of MSIs, derived MSIs, patches and dummy patches (for testing).

The trick here is to patch the decompressed admin image and direct msimsp.exe to create a patch between the unchanged and the changed version of the decompressed admin image. All in all fits your requirement of doing it "by hand".

Write a comment in case something needs clarification.

like image 24
0xC0000022L Avatar answered Sep 19 '22 10:09

0xC0000022L