天天看点

How to add or replace files within MSI file.

These days, I was asked to made an installer for SP1 of the last release of our product. Because the person who made the installer quit, and there are  too many script files (py, bat) to make the installer from getting source code, updating related files, calling deven.exe /rebuild, updating wxs files, calling candle.exe & light.exe, to posting the output msi file to a specified location, neither I or other team members can make it work.

But we can make the project build process work, therefore we can generate the new module files. However, it is really hard to make the process generating MSI work, and there are 7 loccalized installers which need to be updated too. Therefore I planed to directly update MSI file. I searched information from google, but there is no a simple solution, for example, http://www.gameaddict.eu/how-to-add-and-or-replace-files-into-an-msi-file/, and InstEdit can be download from http://www.instedit.com/. Because there are some relationship amoung tables, and the MsiFileHash table will be updated too. In one word, I failed to get it worked.

Finally, an old co-worker suggested me to decompile the MSI to create WXS file and other files, then replace/add files and update the WXS file, lastly compile the WXS to generate new MSI file. I did according to his advice. It did work. What I did are:

1. Use dark.exe tool to decompile the MSI file.

2. Replace/Add files in the folder created by the dark tool.

3. Update the WXS file generated by the dark tool.

4. Use candle.exe and light.exe to create new MSI.

To update all localized installers, I wrote a tool to update the WXS file and some batch script to automatically call the WIX tools.

It is very simple, hope you will obtain help if you run into the same problem.