How to add merge module to WiX setup project

Designer for WiX Toolset

Add-in Express Home > Designer for WiX toolset > Online Guide > Merge module

How to add merge module

Merge modules are used when creating a modular structure of a setup project. A merge module can deploy files and folders to the target machine, create registry entries, specify file types, and deliver/run custom action executables.

When using WiX, you create a merge module project by choosing the project template called Merge Module Project under the Windows Installer XML node in the New Project dialog window of Visual Studio.

A merge module may depend on other merge modules:

Note that your setup project may produce warnings after you add a merge module. Some of the warnings are expected; please refer to wixtoolset.org.

How to add merge module reference to merge module project

In the Solution Explorer window, select a merge module project, choose View | View WiX Editors | File System Editor on the main menu, right-click the root entry (File System on Target Machine) and choose Add Merge Module Reference on the context menu:

Adding a merge module reference

This opens a FileOpen dialog. Select a merge module and add its reference to your project:

Select a merge module and add its reference to your project.

Here's the merge module reference added:

The merge module reference is added.

The files and merge modules the referenced merge module provides are listed in the Files and ModuleDependencies properties; see the screenshot above.

How to add merge module to setup project

In the Solution Explorer window, select a merge module project, choose View | View WiX Editors | File System Editor on the main menu, right-click the root entry (File System on Target Machine) and choose Add Merge Module on the context menu:

Adding a merge module to the setup project.

This opens a FileOpen dialog. Select a merge module and add it to your setup project:

Select a merge module you want to add to your setup project.

Done. The merge module is added to your setup project.

The merge module is added to the setup project.

Adding a module also adds all merge modules referenced by the merge module. The entry policy_8_0_Microsoft_VC80_MFC_x86.msm is shown in the screenshot above because the Microsoft_VC80_MFC_x86.msm merge module references it.

Note that a merge module cannot be moved into a custom folder. In all scenarios you always have it on the level right below the root node. Should you need to deploy a .MSM file as a file (rather than a source of files and folders, registry entries and custom actions), you add it to a folder by right-clicking the folder and choosing Add | File on the context menu.

If however you need to specify the folder where you want the merge module to install its files, you use the Module Retargetable Folder property of the merge module. Note that merge modules supplied by Microsoft are mostly preconfigured so that modifications of the Module Retargetable Folder property do not apply and the files that the merge module provides (see the Files property of the merge module) are delivered to preconfigured system folders.