Installer Package Files and Merge Modules
You can quickly and easily create two types of installation-related package files with Microsoft® Visual Studio® Installer:
Microsoft® Windows®installer package (.msi) files, which include all information and instructions required to provide easy application installation for your users.
Windows merge modules (.msm files), which contain shared code to merge into installer package (.msi) files.
Windows Installer Package (.msi) Files
Self-installing Windows installer package (.msi) files contain all the information necessary for your end users to install your application. The .msi file is a single, convenient package containing all elements of an application installation, including the files installed and any accompanying registry information, dependency data, installation instructions, and so on. With all this information in a single package, a well-written .msi file can handle many different installation scenarios, including installing:
On different platforms.
With different sets of existing applications.
Over previous versions of a product.
To different default installation locations.
You can package .msi files in any of three formats to accommodate your distribution and user requirements:
A single .msi file including compressed cabinet (.cab) file copies of all files required for the installation.
Installer package file including .cab files
An .msi file and separate compressed .cab file copies of all files required for the installation.
Installer package file plus .cab files
An .msi file and separate uncompressed copies of all other files required for the application installation.
Installer package file plus uncompressed files
With Visual Studio Installer, you select how to package your .msi file by setting your installer project's build properties (after you create the project). For information about creating installer projects, see Creating and Opening Installer Projects. For information about setting build properties, see Build Tab (Project Properties Dialog Box).
Merge Modules (.msm Files)
A Windows merge module (.msm file) is a single package that includes all files, resources, registry entries, and setup logic to install some shared files. Installer package (.msi) files incorporate .msm files in order to correctly install shared files.
Just as .msi files contain all the information necessary to install an application, .msm files include all the information necessary to install shared files. Unlike .msi files, however, users do not run .msm files. Instead, .msm files are merged into and become part of .msi files.
Sharing a Merge Module
For example, suppose Application1 and Application2 both include a shared FileY in their installation instructions. If FileY has been packaged as a merge module, FileY.msm, multiple installer package files (such as Application1.msi and Application2.msi) can include all the information required to install FileY by referring to FileY.msm.
Two installers (.msi) files sharing a merge module (.msm file)
Referring to the same .msm file from both installers (.msi) files also ensures both applications install the same version and configuration of the shared file.
When the .msm file is merged, all the merge module information about the shared file becomes part of the installer package file. The merge module has done its job — your end user never has to see the merge module file. The user requires only the single .msi file. When your user runs the installer, the .msi file references the .msm file and correctly installs its shared files.
Benefits of Using Merge Module (.msm Files)
Merge modules support standardized code sharing and are the easiest and most reliable method for sharing files among Windows application installers. Because all the information required to install a shared file is delivered to the installer in a single, standardized .msm file, using .msm files with the Windows installer can help eliminate many instances of version clashing, missing registry entries, and improperly installed files.
Another important reason to install shared files with .msm files is to make it possible for Windows to track which applications use a shared file. If shared files are installed from .msm files, the Windows installer can keep a correct reference list of applications that use those shared files. Each time the Windows installer installs a shared file using a merge module, the installer adds the installed application to its reference list of applications it has installed that include the shared file.
When the Windows installer uninstalls an application that uses an .msm shared file, the installer removes the uninstalled product's name from the shared file's reference list. By tracking exactly which applications still use which shared files (providing those shared files were installed by merge modules), Windows can better avoid deleting shared resources used by any application until the last application using them is uninstalled.
This tracking process provides a significant benefit over traditional installers, which keep an incremental reference count of the number of applications using a shared file, but not the name of the application. Traditionally, as applications were uninstalled, updated, and reinstalled, errors could be introduced into the incremental reference count. Many of the dynamic-link library (.dll) file issues traditionally associated with application installations stemmed from reference count errors. Because the Windows installer can use .msm file information to keep a current list of exactly which applications use which shared files, distributing shared files in .msm files helps to reduce these problems.
For these reasons, Microsoft recommends the use of .msm files for code sharing among application installers.
Obtaining Merge Modules (.msm Files) for Your Installer
Packaging shared files in .msm files is essential for correctly authoring Windows installer package (.msi) files. Visual Studio Installer provides many common Microsoft .msm files ready for you to merge into your installer package (.msi) files, including:
The Microsoft® Visual Basic® run-time file.
Microsoft Foundation Classes (MFC).
Active Template Library (ATL).
In addition, some third-party vendors distribute their shared files in .msm file format. Visual Studio Installer provides a workaround for cases when a vendor does not have a shared file packaged in an .msm file. For more information about the workaround, see .
Note Unlike all other merge modules Visual Studio Installer provides, the mdac.msm file does not install Microsoft® Data Access Components when the installer package it belongs to is run. Instead, mdac.msm simply checks for the presence of Microsoft Data Access Components on the target machine.
You can easily incorporate .msm files into your Visual Studio Installer projects.
Distributing Merge Modules (.msm Files)
If you want to share a file you have developed, you should author and package the file as an .msm file. You can create .msm files with Visual Studio Installer.
Merge Modules (.msm Files) in Visual Studio Installer
Visual Studio Installer makes it easy for you to create and consume merge modules. To create a merge module, you can configure your installer project as an .msm file, which provides information for installing a shared component to installer package (.msi) files. For information about how to do this, see Build Type in Build Tab (Project Properties Dialog Box).
Important Create .msm files only for shared code you own or author. To add third-party shared code that is not distributed in an .msm file to your installer, you must set the appropriately. Do not reformat or include third-party shared code as an .msm file.
To consume a merge module, your installer package (.msi) file can include the appropriate .msm file. For information about including .msm files in an installer project, see Adding Merge Modules to an Installer Project.