Walkthrough: Installing Shared Components Using Merge Modules
Merge modules (.msm) are used to install components that are shared by multiple applications—for example, components (such as DLLs, controls, resources) that developers use in applications. In contrast, Windows installers (.msi) are used to install applications and files (such as executable files, documents, HTML pages), and are typically used by the end user of the application.
By using merge modules, you can help ensure that shared components are packaged and delivered for consistent deployment. You can use the module's retargetable folder to place files into the same directory as your application, but you can also opt to place files to another directory, such as the Start Menu.
This walkthrough demonstrates how to package a component in a merge module and to consume that merge module in a setup project.
Note
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
To create a component
On the File menu, point to New, and then choose Project.
In the New Project dialog box, select Visual C# Projects in the Project Type pane, and then choose Class Library in the Templates pane. In the Name box, type MyComponent.
Click OK to close the dialog box.
On the Build menu, choose Build MyComponent to build the class library.
To create a merge module project
On the File menu, point to Add, and then choose New Project.
In the Add New Project dialog box, select Other Project Types, select Setup and Deployment Projects in the Project Type pane, select Visual Studio Installer, and then choose Merge Module Project in the Templates pane. In the Name box, type Sample.
Click OK to close the dialog box.
In the File System Editor, select the Module Retargetable Folder. On the Action menu, point to Add, and then choose Project Output.
In the Add Project Output Group dialog box, select the Primary Output of the MyComponent project. Click OK to close the dialog box.
On the Build menu, choose Build Sample to build the merge module.
To add a Setup project that consumes the merge module
On the File menu, point to Add, then click New Project.
In the Add New Project dialog box, select Setup and Deployment Projects in the Project Type pane, and then choose Setup Project in the Templates pane. In the Name box, type Merge Module Installer.
Click OK to close the dialog box.
In the File System Editor, select the Application Folder. On the Action menu, point to Add, and then choose Project Output.
In the Add Project Output Group dialog box, select the Sample project, then select Merge Module.
Click OK to close the dialog box.
Note that the merge module (Merge Module from Sample (Active)) is not added to the folder. Instead, it is added to the Merge Module Installer project in Solution Explorer. This is because merge modules cannot be installed directly; they must be merged into an installer.
Select the merge module in Solution Explorer. In the Properties window, expand the KeyOutput node, then expand the (Merge Module Properties) node, and select the Module Retargetable Folder property.
Note
The properties beneath the KeyOutput property are dynamic properties that do not appear until the merge module has been built.
Click the drop-down list for the Module Retargetable Folder property and select (Browse...) to display the Select Folder dialog box.
In the Select Folder dialog box, choose Application Folder. Click OK to close the dialog box.
On the Build menu, choose Build Merge Module Installer.
To install on your development computer
Select the Merge Module Installer project in Solution Explorer. On the Project menu, choose Install.
This will run the installer and install Merge Module Installer on your development computer. The installer will install the component contained in the merge module to the application directory.
Note
You must have install permissions on the computer in order to run the installer.
To deploy to another computer
In Windows Explorer, navigate to your project directory and find the built installer. The default project configuration is Debug or Release.
Copy Merge Module Installer.msi, Setup.exe, and all other files and subdirectories in the directory to another computer.
Note
To install on a computer that is not on a network, copy the files to traditional media such as CD-ROM.
On the target computer, double-click the Setup.exe file to run the installer.
Note
You must have install permissions on the target computer in order to run the installer.
To uninstall the application
In Windows Control Panel, double-click Add or Remove Programs.
In the Add/Remove Programs dialog box, select Merge Module Installer and click Remove.
Click OK to close the dialog box.
Tip
To uninstall from your development computer, on the Project menu of Visual Studio, choose Uninstall.
See Also
Reference
Dynamic Properties for Merge Modules