Creating Merge Modules

Windows Installer XML

Creating a Merge Module

Creating a Merge Module is very much like creating a Windows Installer package.

Step 1: Create the WiX source file

Create a new text file called "module.wxs" and put the standard skeleton in it:

<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
</Wix>

Step 2: Author the content of the package

To create a Merge Module, we add the <Module/> element and add the required attributes:

<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Module Id='TestModule' Language='1033' Version='1.0.0.0'>
      <Package Id='PUT-GUID-HERE' Description='My first Merge Module'
                Comments='This is my first attempt at creating a Windows Installer Merge Module'
                Manufacturer='Microsoft Corporation' InstallerVersion='200' />

   </Module>
</Wix>

Replace PUT-GUID-HERE with a GUID value.

Step 3: Adding a file to the package

Then create a text file called readme2.txt and update the source code to include the new file:

<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Module Id='TestModule' Language='1033' Version='1.0.0.0'>
      <Package Id='PUT-GUID-HERE' Description='My first Merge Module'
                Comments='This is my first attempt at creating a Windows Installer Merge Module'
                Manufacturer='Microsoft Corporation' InstallerVersion='200' />
 
      <Directory Id='TARGETDIR' Name='SourceDir'>
         <Directory Id='MyModuleDirectory' Name='.'>
            <Component Id='MyModuleComponent' Guid='PUT-GUID-HERE'>
               <File Id='readme2' Name='readme2.txt' Source='readme2.txt' />
            </Component>
         </Directory>
      </Directory>
   </Module>
</Wix>

Replace PUT-GUID-HERE with a GUID value.

Step 4: Build the package

Now let's build the package using the following instructions:

C:\test> candle module.wxs
Microsoft (R) Windows Installer Xml Compiler version 1.0.1220.15022
Copyright (C) Microsoft Corporation 2003. All rights reserved
 
module.wxs
 
C:\test> light module.wixobj
Microsoft (R) Windows Installer Xml Linker version 1.0.1220.15022
Copyright (C) Microsoft Corporation 2003. All rights reserved

That's it! You now have a Merge Module that can be shared with other teams to install your "readme2.txt" file. Now that we have a Merge Module, let's actually use it in a Windows Installer package. See Incorporating a Merge Module