views:

812

answers:

2

I am currently making changes to my company's enterprise library and I am looking into creating a deployment project that will allows developer to set up the library through the MSI installer or some type of set up executable.

I was looking into using a Merge Module project to accomplish this task. A basic google search did not produce any helpful resources for using Merge Module Product.

Do anyone know of useful resource/tutorial on creating Merge Module projects or do they have a better suggestion for accomplishing this task?

UPDATE

I was able to build my Merge Module project with the appropriate references to all the need assemblies. It produced a .MSM file. What is the next step to actually run and test it?

+1  A: 

I faced the same lack of documentation when I built my only merge module using Visual Studio 2005. I had some experience with the MSI Setup projects, and I simply applied the information I had for the MSI Setup projects to the MSM.

In Visual Studio 2005 (or 2008), both MSI and MSM projects are handled in a very similar manner. Add files to the project (either explicitly or through a reference to another project found in the same solution), then use the right-click on the project to :

  1. View the file system.
  2. View the registry settings.
  3. View the file types associations.
  4. View the custom actions.

Custom actions can be implemented in a .NET assembly, for instance, by subclassing the Installer class. Here is an example which would, for instance, install or uninstall a printer when the MSM/MSI gets installed or uninstalled:

using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;

namespace Epsitec.PostScriptPrinterInstaller
{
    [RunInstaller (true)]
    public partial class PrinterInstaller : Installer
    {
        public PrinterInstaller()
        {
            this.InitializeComponent ();
        }
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install (stateSaver);
            string sysroot = System.Environment.GetEnvironmentVariable ("SystemRoot");
            string infpath = @"""" + System.IO.Path.Combine (sysroot, @"inf\ntprint.inf") + @"""";
            ProcessStartInfo info;
            Process process;

            info = new ProcessStartInfo ("rundll32.exe",
                       @"printui.dll,PrintUIEntry /if /b ""PostScript"" /m ""MS Publisher Color Printer"" /f "+infpath+@" /r ""FILE:""");

            process = Process.Start (info);
            process.WaitForExit ();
        }

        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall (savedState);
            ProcessStartInfo info;
            info = new ProcessStartInfo ("rundll32.exe",
                       @"printui.dll,PrintUIEntry /dl /n ""PostScript""");
            Process process = Process.Start (info);
            process.WaitForExit ();

            info = new ProcessStartInfo ("rundll32.exe",
                       @"printui.dll,PrintUIEntry /dd /m ""MS Publisher Color Printer""");
            process = Process.Start (info);
            process.WaitForExit ();
        }
    }
}

I hope that with this information, you will be able to do some progress.

Pierre
I have updated my question in response to your answer
Michael Kniskern
Feel free to up vote the replies you find useful on this site, or accept one of the answers; this is both positive for the people who answered and for the people who'll be interested in the same topic as you and who will know: aha there were good answers there!
Pierre
+1  A: 

An MSM cannot be run or tested per se. However, you can embed it into an MSI and then simply try to install the MSI using the standard tools (i.e. either manually right-clicking on the MSI and selecting Install or Uninstall, do so using Visual Studio, or by executing the corresponding msiexec.exe commands).

To embed an MSM into an MSI, the easiest way is to create a setup project in Visual Studio and add the Merge Module from the merge module project you have just created in your solution. This will automatically reference the MSM file and include it into the MSI.

Pierre
Another developer helped me with setting up a Visual Studio project and referencing the MSM file in the project and adding project output to the setup project.
Michael Kniskern
Great! So now you have a solution with two setup projects in it: an MSM project and an MSI project referencing the MSM. Did you achieve what you were trying to do?
Pierre