## Building WinMerge Installer

### Needed programs:

- Inno Setup version 5.2.3.
- ISTool recommended - great help managing Inno Setup installer scripts

There is download package called "QuickStart Pack" available in Inno Setup downloads. It contains all needed components in one installer.

### Installer script:

Installer script is in `Installer/InnoSetup` folder: `WinMerge.iss`

### Checklist:

- Installer reads version number from `WinMergeU.exe`. So make sure you have version resource correctly set.
  There is Python script `Tools/Scripts/SetVersions.py` which sets version numbers to all components. The script reads version numbers from `/versions.ini` file. See more info about the script from `Tools/Scripts/SetVersions.txt`
- Installer checks that files listed are present. But some files are included as folder (like `/Plugins/Dlls`) or as filemask (like `*.flt`) so take extra care to make sure all needed files are present in locations shown below.

### Folder structure and files needed:

First make sure you have all needed files compiled and available:

- WinMerge executable: `WinMergeU.exe`
- Translation library: `MergeLang.dll`
- Executable translations: `/Translations/WinMerge/*.po`
- Libraries: `libexpat.dll` and `pcre.dll`
- Manual: `WinMerge.chm`
- ShellExtension: `ShellExtensionU.dll` and `ShellExtensionX64.dll`
- Documents: `/Docs/Users/*`
- Filters: `/Filters/*`

These files are produced by compiling WinMerge, documentation etc, but that's not subject of this document, refer to Compiling.html, readme-manual.html and Translations.html.

In addition you will need Microsoft C- and MFC-runtime files. Those files are not distributes with WinMerge. Older WinMerge installers copied those runtime files to WinMerge program folder. But with VS 2005 and later this has caused a lot of installing problems for users. So now we are embedding MS's own runtime installer executable to our installer. This makes the installer executable considerable bigger but seems to be the only reliable way to install those runtime files.

You can download the latest VC2008 runtimes installer from MS: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2051A0C1-C9B5-4B0A-A8F5-770A549FD78C

#### Folder structure

Copy or move the WinMerge files into the following layout (not runtimes):

- `Build/`
  - `expat`
    - `libexpat.dll`
  - `Manual/htmlhelp`
    - `WinMerge.chm`
  - `MergeUnicodeRelease/`
    - `MergeLang.dll`
    - `ShellExtensionU.dll`
    - `WinMergeU.exe`
  - `pcre/`
    - `pcre.dll`
  - `ShellExtensionX64/`
    - `ShellExtensionX64.dll`
- `Docs/`
  - `Users`
    - Copy the entire `Docs/Users` folder to here
- `Filters/`
  - `FileFilter.tmpl`
  - `*.flt`
- `Installer/`
  - `InnoSetup/`
    - Copy the entire `Installer/InnoSetup` folder to here
- `Plugins/`
  - `dlls/`
    - Copy the entire `Plugins/dlls` folder to here
- `Translations/`
  - `Docs`
    - `*.*`
  - `WinMerge`
    - `*.po`

NOTE
If you don't need or can't compile `ShellExtensionX64.dll` component, comment or remove line:

    ; 64-bit version of ShellExtension
    Source: ..\..\Build\ShellExtensionX64\ShellExtensionX64.dll; [...]

from `WinMerge.iss`

#### Runtime files installer

Runtime files installer must be copied to the `Runtimes`-folder in same level than WinMerge source tree folder is. Not inside source tree but outside of the source tree.

### Running Inno Setup to create installer

`WinMerge.iss` (in `InnoSetup` folder) is script used to create WinMerge installer.

Rest of this section assumes ISTool is used. If not, then refer to InnoSetup manual for creating installer from script.

1. Start ISTool and load `WinMerge.iss`
2. Select "Project->Verify Files..." from ISTool menu to verify all needed files are present and in correct directories. Copy missing files to correct directories before continuing.
3. Select "Project->Compile Setup" from ISTool menu to create installer. This takes a while...

If compile succeeds you have `WinMerge-[version]-Setup.exe` in folder `/Build`. You probably want to remove unnecessary zeros from the filename before uploading: if filename is `WinMerge-2.6.0.0-Setup.exe`, you may want to rename it to `WinMerge-2.6-Setup.exe`. Not a rule, but a recommendation.

Test installer!