Creating Merge Modules

Windows Installer XML

Incorporating a Merge Module into a .wxs File

Merge Modules can only be merged into Windows Installer packages. Once you have a .wxs file that creates a Windows Installer package, it's just a matter of adding two lines (yes, only two lines are necessary) to merge a new Module. In your .wxs source file, add the following lines:

<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product Id='PUT-GUID-HERE' Name='Test Package' Language='1033'
             Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
      <Package Description='My first Windows Installer package'
               Comments='This is my first attempt at creating a Windows Installer database'
               Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />
 
      <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
 
      <Directory Id='TARGETDIR' Name='SourceDir'>
         <Directory Id='ProgramFilesFolder' Name='PFiles'>
            <Directory Id='MyDir' Name='Test Program'>
               <Component Id='MyComponent' Guid='PUT-GUID-HERE'>
                  <File Id='readme' Name='readme.txt' DiskId='1' Source='readme.txt' />
               </Component>
 
               <Merge Id='MyModule' Language='1033' SourceFile='module.msm' DiskId='1' />
            </Directory>
         </Directory>
      </Directory>
 
      <Feature Id='MyFeature' Title='My 1st Feature' Level='1'>
         <ComponentRef Id='MyComponent' />
         <MergeRef Id='MyModule' />
      </Feature>
   </Product>
</Wix>

Now when you compile your Windows Installer package source file, it will include the installation logic and files from the Merge Module.

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

Now when you install the package, you will see that it creates a directory called "Test Program" in your system's "Program Files" folder. The files readme.txt and readme2.txt will be installed in the "Test Program" directory.