Merge Modules are a feature of Windows Installer that provides a standard method for delivering components, ensuring that the correct version of a component is installed. Merge Modules is something that we would give to a developer and not the end user. For example, if we want to distribute our DLL to another developer, we’ll create a Merge Module for it and distribute our DLL in a Merge Module. While deploying a finished product the developer will include this Merge Module in his MSI project and give it to the end user. Merge Modules are used to install components that are shared by multiple applications.
Now let us proceed with creation of a Merge Module. Here we have assumed that a Class Library stands created and the .DLL named ‘mylib.dll’ is ready. To create a merge module we need to select Merge Module from the project templates available and name it, say mergesetup. On doing so we are taken to the File System Editor. The File System Editor is shown in the following figure.
The File System Editor has two folders—Common Files Folder and Module Retargetable Folder falling under ‘File System on Target machine’. Files present in a Merge Module are generally sharable files hence Common Files Folder is a good option to deploy the files. Whichever file we copy in this folder gets deployed to the Common Files folder of the target machine. Here too we have an option of adding special folders to the File System Editor by right clicking on the left pane and selecting the desired folder. Files deployed in these folders would get deployed to corresponding folders on the target machine.
Next we need to change two of the properties of the Web Application Folder. First we have to set the AllowDirectoryBrowsing property to True. This property determines whether users can see a hypertext listing of files and subdirectories in a virtual directory. If it is set to True, users can browse for it. Next we have to set the VirtualDirectory property to myweb. Now we need to build websetup and copy the ‘websetup.msi’ file to the web server. On double clicking the MSI file the project would get installed. To test the project we need to start Internet Explorer and type the ‘http:\\computername\myweb’ URL. You will see the name of the ‘windowsapp1.exe’ file in the browser window. On clicking filename the EXE would get executed. For the second scenario we need to follow the same steps as given above, but instead of copying the EXE to the Web Application Folder, we need to copy an MSI (winsetup.msi) project, which includes the EXE to the folder. Then on deploying and installing ‘websetup.msi’ we would get the window displaying the name of the ‘websetup.msi’ file. On clicking it we would be presented with a dialog box that gives us options to install or download the MSI. On installing or downloading the MSI we would be able to execute the Windows application.
As told to you earlier the Setup Wizard helps us to start the deployment projects. The wizard guides us through the steps of creating setup program that contains all information required for installation. The steps in the Setup Wizard are self-explanatory. As soon as we select Setup Wizard, give the project a name (say wizsetup) and press OK, we are presented with a Welcome dialog.
On clicking ‘Next’ we are presented with the Step 2 window of the wizard. It asks us type of project we intend to make. Suppose we select the first option and click ‘Next’, we get the third dialog box. Here the Wizard asks us to add the files we wish to deploy. We can add the files by clicking on the ‘Add’ button and browsing for the desired files. On clicking the ‘Next’ button the Wizard presents us with the summary of the project. We had selected the first option and hence on clicking the ‘Finish’ button the Wizard takes us to the File System Editor of the project. We can now build the project as we would build any deployment project.