Re: Installing MSMQ as dependency [P]

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Installing MSMQ as dependency [P]

Steve-Ogilvie
Classification: Public
I have the same requirements and ended up writing a custom action to do the work for me:
>From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use ocsetup.exe (we use MSMQ for our Server product and our Client product), however Microsoft being so consistent (being sarcastic) the features for MSMQ change from OS to OS :( so I ended up doing something like this:
[CustomAction]
        public static ActionResult CheckToSeeIfMSMQIsInstalled(Session session)
        {
            var productName = string.Empty;
            try
            {
                if (session == null)
                {
                    throw new ArgumentNullException("session");
                }

                var tempString = GetSessionProperty(session, "CustomActionData", false);
                var parts = tempString.Split(new[] { '|' });
                productName = parts[0];

                var serviceExists = ServiceController.GetServices().Any(s => s.ServiceName == "MSMQ");
                if (!serviceExists)
                {
                    var platformVersion = Environment.OSVersion.VersionString;

                    var cmdLineParameters = string.Empty;
                    if (platformVersion.Contains("6.0.600") && !Os.IsWindowsServer())
                    {
                        // Windows Vista
                        cmdLineParameters = "MSMQ-Container;MSMQ-Server /quiet /norestart";
                    }
                    else if ((platformVersion.Contains("6.1.760") && !Os.IsWindowsServer())
                             || (platformVersion.Contains("6.2.920") && !Os.IsWindowsServer()))
                    {
                        // Windows 7 and Windows 8
                        cmdLineParameters = "/Online /NoRestart /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server";
                    }
                    else if (platformVersion.Contains("6.1.760") && Os.IsWindowsServer())
                    {
                        // Windows Server 2008 R2
                        cmdLineParameters = "/Online /NoRestart /Enable-Feature /featurename:MSMQ-Server";
                    }
                    else if (platformVersion.Contains("6.2.920") && Os.IsWindowsServer())
                    {
                        // Windows Server 2012
                        cmdLineParameters = "/Online /NoRestart /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services /featurename:MSMQ-Server";
                    }

                    string cmdLineExe;
                    if (platformVersion.Contains("6.0.600") && !Os.IsWindowsServer())
                    {
                        // Windows Vista
                        cmdLineExe = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\ocsetup.exe";
                    }
                    else
                    {
                        // Windows 7 / 8 / 2008R2 / 2012
                        var system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "system32");
                        if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
                        {
                            // For 32-bit processes on 64-bit systems, %windir%\system32 folder
                            // can only be accessed by specifying %windir%\sysnative folder.
                            system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "sysnative");
                        }

                        // Windows 7 / 8 / 2008R2 / 2012
                        cmdLineExe = system32Directory + "\\dism.exe";
                    }

                    // Install MSMQ if missing
                    var runDismInfo = new ProcessStartInfo
                    {
                        UseShellExecute = true,
                        Arguments = cmdLineParameters,
                        FileName = cmdLineExe,
                        WindowStyle = ProcessWindowStyle.Hidden,
                        CreateNoWindow = true
                    };

                    // Run the external process & wait for it to finish
                    using (var runDismProc = Process.Start(runDismInfo))
                    {
                        runDismProc.WaitForExit();
                    }
                }
            }
            catch (Exception ex)
            {
                WriteErrorLogInstall(session, "CheckToSeeIfMSMQIsInstalled failed: ", ex, true);
                if (session != null)
                {
                    session.Message(
                        InstallMessage.User + (int)MessageBoxIcon.Error + (int)MessageBoxButtons.OK,
                        new Record { FormatString = productName + " requires Microsoft Message Queuing Service (MSMQ). Setup failed to install MSMQ, please go to Programs and Features and turn this feature on 'Microsoft Message Queue (MSMQ) Server'." });
                }

                return ActionResult.Failure;
            }

            return ActionResult.Success;
        }


private class Os
        {
            /// <summary>
            /// The OS ANYSERVER.
            /// </summary>
            [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Reviewed. Suppression is OK here.")] // ReSharper disable InconsistentNaming
            private const int OS_ANYSERVER = 29; // ReSharper restore InconsistentNaming

            /// <summary>
            /// Prevents a default instance of the <see cref="Os"/> class from being created.
            /// </summary>
            private Os()
            {
            }

            /// <summary>
            /// The is windows server.
            /// </summary>
            /// <returns>
            /// The <see cref="bool"/>.
            /// </returns>
            public static bool IsWindowsServer()
            {
                return Os.IsOS(OS_ANYSERVER);
            }

            [DllImport("shlwapi.dll", SetLastError = true, EntryPoint = "#437")]
            private static extern bool IsOS(int os);
        }

Steve


-----Original Message-----
From: José Marques [mailto:[hidden email]]
Sent: July-24-13 6:18 AM
To: [hidden email]
Subject: [WiX-users] Installing MSMQ as dependency

Hello all,

On the installer I'm currently developing, I need to install Microsoft Message Queue (MSMQ) as a dependency. Depending on Windows version, I need to run ocsetup.exe or sysocmgr.exe. No issues with ocsetup, my problem relies with sysocmgr.
So far I've thought of two ways to do it: add an ExePackage to my existing bundle, or setting a custom action.
Either way, the issues I'm currently having is:

- If i do it in the bundle, i need to provide the .exe file, which I think it is not recommended, I have to call it. (correct me if I'm wrong)
- I need to pass a file with MSMQ options as a parameter, is this possible?
(I didn't anything remotely close with this)

If there's another simple and/or correct way of installing MSMQ let me know as well :)

Thank you for your help,

José Marques
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/wix-users

 
This message has been marked as Public by Steven Ogilvie on July-24-13 9:09:47 AM.

The above classification labels were added to the message by TITUS Message Classification. For more information visit www.titus.com.

 



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/wix-users
Reply | Threaded
Open this post in threaded view
|

Re: Installing MSMQ as dependency [P]

JoeMarks
Thank you for your reply.
I am a bit new to Wix, as this is the first time I'm making an installer,
where exactly do you write that code? I presume it's not straight into the
xml, but so far I only have written XML...

Best regards,
José

On Wed, Jul 24, 2013 at 2:09 PM, Steven Ogilvie <[hidden email]>wrote:

> Classification: Public
> I have the same requirements and ended up writing a custom action to do
> the work for me:
> >From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use
> ocsetup.exe (we use MSMQ for our Server product and our Client product),
> however Microsoft being so consistent (being sarcastic) the features for
> MSMQ change from OS to OS :( so I ended up doing something like this:
> [CustomAction]
>         public static ActionResult CheckToSeeIfMSMQIsInstalled(Session
> session)
>         {
>             var productName = string.Empty;
>             try
>             {
>                 if (session == null)
>                 {
>                     throw new ArgumentNullException("session");
>                 }
>
>                 var tempString = GetSessionProperty(session,
> "CustomActionData", false);
>                 var parts = tempString.Split(new[] { '|' });
>                 productName = parts[0];
>
>                 var serviceExists = ServiceController.GetServices().Any(s
> => s.ServiceName == "MSMQ");
>                 if (!serviceExists)
>                 {
>                     var platformVersion =
> Environment.OSVersion.VersionString;
>
>                     var cmdLineParameters = string.Empty;
>                     if (platformVersion.Contains("6.0.600") &&
> !Os.IsWindowsServer())
>                     {
>                         // Windows Vista
>                         cmdLineParameters = "MSMQ-Container;MSMQ-Server
> /quiet /norestart";
>                     }
>                     else if ((platformVersion.Contains("6.1.760") &&
> !Os.IsWindowsServer())
>                              || (platformVersion.Contains("6.2.920") &&
> !Os.IsWindowsServer()))
>                     {
>                         // Windows 7 and Windows 8
>                         cmdLineParameters = "/Online /NoRestart
> /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server";
>                     }
>                     else if (platformVersion.Contains("6.1.760") &&
> Os.IsWindowsServer())
>                     {
>                         // Windows Server 2008 R2
>                         cmdLineParameters = "/Online /NoRestart
> /Enable-Feature /featurename:MSMQ-Server";
>                     }
>                     else if (platformVersion.Contains("6.2.920") &&
> Os.IsWindowsServer())
>                     {
>                         // Windows Server 2012
>                         cmdLineParameters = "/Online /NoRestart
> /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services
> /featurename:MSMQ-Server";
>                     }
>
>                     string cmdLineExe;
>                     if (platformVersion.Contains("6.0.600") &&
> !Os.IsWindowsServer())
>                     {
>                         // Windows Vista
>                         cmdLineExe =
> Environment.GetFolderPath(Environment.SpecialFolder.System) +
> "\\ocsetup.exe";
>                     }
>                     else
>                     {
>                         // Windows 7 / 8 / 2008R2 / 2012
>                         var system32Directory =
> Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
> "system32");
>                         if (Environment.Is64BitOperatingSystem &&
> !Environment.Is64BitProcess)
>                         {
>                             // For 32-bit processes on 64-bit systems,
> %windir%\system32 folder
>                             // can only be accessed by specifying
> %windir%\sysnative folder.
>                             system32Directory =
> Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
> "sysnative");
>                         }
>
>                         // Windows 7 / 8 / 2008R2 / 2012
>                         cmdLineExe = system32Directory + "\\dism.exe";
>                     }
>
>                     // Install MSMQ if missing
>                     var runDismInfo = new ProcessStartInfo
>                     {
>                         UseShellExecute = true,
>                         Arguments = cmdLineParameters,
>                         FileName = cmdLineExe,
>                         WindowStyle = ProcessWindowStyle.Hidden,
>                         CreateNoWindow = true
>                     };
>
>                     // Run the external process & wait for it to finish
>                     using (var runDismProc = Process.Start(runDismInfo))
>                     {
>                         runDismProc.WaitForExit();
>                     }
>                 }
>             }
>             catch (Exception ex)
>             {
>                 WriteErrorLogInstall(session, "CheckToSeeIfMSMQIsInstalled
> failed: ", ex, true);
>                 if (session != null)
>                 {
>                     session.Message(
>                         InstallMessage.User + (int)MessageBoxIcon.Error +
> (int)MessageBoxButtons.OK,
>                         new Record { FormatString = productName + "
> requires Microsoft Message Queuing Service (MSMQ). Setup failed to install
> MSMQ, please go to Programs and Features and turn this feature on
> 'Microsoft Message Queue (MSMQ) Server'." });
>                 }
>
>                 return ActionResult.Failure;
>             }
>
>             return ActionResult.Success;
>         }
>
>
> private class Os
>         {
>             /// <summary>
>             /// The OS ANYSERVER.
>             /// </summary>
>             [SuppressMessage("StyleCop.CSharp.NamingRules",
> "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Reviewed.
> Suppression is OK here.")] // ReSharper disable InconsistentNaming
>             private const int OS_ANYSERVER = 29; // ReSharper restore
> InconsistentNaming
>
>             /// <summary>
>             /// Prevents a default instance of the <see cref="Os"/> class
> from being created.
>             /// </summary>
>             private Os()
>             {
>             }
>
>             /// <summary>
>             /// The is windows server.
>             /// </summary>
>             /// <returns>
>             /// The <see cref="bool"/>.
>             /// </returns>
>             public static bool IsWindowsServer()
>             {
>                 return Os.IsOS(OS_ANYSERVER);
>             }
>
>             [DllImport("shlwapi.dll", SetLastError = true, EntryPoint =
> "#437")]
>             private static extern bool IsOS(int os);
>         }
>
> Steve
>
>
> -----Original Message-----
> From: José Marques [mailto:[hidden email]]
> Sent: July-24-13 6:18 AM
> To: [hidden email]
> Subject: [WiX-users] Installing MSMQ as dependency
>
> Hello all,
>
> On the installer I'm currently developing, I need to install Microsoft
> Message Queue (MSMQ) as a dependency. Depending on Windows version, I need
> to run ocsetup.exe or sysocmgr.exe. No issues with ocsetup, my problem
> relies with sysocmgr.
> So far I've thought of two ways to do it: add an ExePackage to my existing
> bundle, or setting a custom action.
> Either way, the issues I'm currently having is:
>
> - If i do it in the bundle, i need to provide the .exe file, which I think
> it is not recommended, I have to call it. (correct me if I'm wrong)
> - I need to pass a file with MSMQ options as a parameter, is this possible?
> (I didn't anything remotely close with this)
>
> If there's another simple and/or correct way of installing MSMQ let me
> know as well :)
>
> Thank you for your help,
>
> José Marques
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics Get
> end-to-end visibility with application monitoring from AppDynamics Isolate
> bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> WiX-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
>
> This message has been marked as Public by Steven Ogilvie on July-24-13
> 9:09:47 AM.
>
> The above classification labels were added to the message by TITUS Message
> Classification. For more information visit www.titus.com.
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> WiX-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/wix-users
Reply | Threaded
Open this post in threaded view
|

Re: Installing MSMQ as dependency [P]

Steve-Ogilvie
Classification: Public
I have written a custom action C# DLL

The custom action is called within the product.wxs:

<CustomAction Id="CA_SetCHECKFORMSMQ" Property="CA_CHECKFORMSMQ" Value="$(var.ProductName)"/>
    <CustomAction Id="CA_CHECKFORMSMQ" BinaryKey="BIN_CustomAction" DllEntry="CheckToSeeIfMSMQIsInstalled" Impersonate="no" Execute="deferred" Return="check"/>
    <UI>
      <ProgressText Action="CA_CHECKFORMSMQ">CA: Checking for Microsoft Message Queuing Service (MSMQ)...</ProgressText>
    </UI>

<Custom Action="CA_SetCHECKFORMSMQ" After="CostFinalize">NOT Installed</Custom> <Custom Action="CA_CHECKFORMSMQ" After="InstallInitialize">NOT Installed</Custom>

-----Original Message-----
From: José Marques [mailto:[hidden email]]
Sent: July-24-13 9:22 AM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] Installing MSMQ as dependency [P]

Thank you for your reply.
I am a bit new to Wix, as this is the first time I'm making an installer, where exactly do you write that code? I presume it's not straight into the xml, but so far I only have written XML...

Best regards,
José

On Wed, Jul 24, 2013 at 2:09 PM, Steven Ogilvie <[hidden email]>wrote:

> Classification: Public
> I have the same requirements and ended up writing a custom action to
> do the work for me:
> >From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use
> ocsetup.exe (we use MSMQ for our Server product and our Client
> product), however Microsoft being so consistent (being sarcastic) the
> features for MSMQ change from OS to OS :( so I ended up doing something like this:
> [CustomAction]
>         public static ActionResult CheckToSeeIfMSMQIsInstalled(Session
> session)
>         {
>             var productName = string.Empty;
>             try
>             {
>                 if (session == null)
>                 {
>                     throw new ArgumentNullException("session");
>                 }
>
>                 var tempString = GetSessionProperty(session,
> "CustomActionData", false);
>                 var parts = tempString.Split(new[] { '|' });
>                 productName = parts[0];
>
>                 var serviceExists =
> ServiceController.GetServices().Any(s
> => s.ServiceName == "MSMQ");
>                 if (!serviceExists)
>                 {
>                     var platformVersion =
> Environment.OSVersion.VersionString;
>
>                     var cmdLineParameters = string.Empty;
>                     if (platformVersion.Contains("6.0.600") &&
> !Os.IsWindowsServer())
>                     {
>                         // Windows Vista
>                         cmdLineParameters =
> "MSMQ-Container;MSMQ-Server /quiet /norestart";
>                     }
>                     else if ((platformVersion.Contains("6.1.760") &&
> !Os.IsWindowsServer())
>                              || (platformVersion.Contains("6.2.920")
> &&
> !Os.IsWindowsServer()))
>                     {
>                         // Windows 7 and Windows 8
>                         cmdLineParameters = "/Online /NoRestart
> /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server";
>                     }
>                     else if (platformVersion.Contains("6.1.760") &&
> Os.IsWindowsServer())
>                     {
>                         // Windows Server 2008 R2
>                         cmdLineParameters = "/Online /NoRestart
> /Enable-Feature /featurename:MSMQ-Server";
>                     }
>                     else if (platformVersion.Contains("6.2.920") &&
> Os.IsWindowsServer())
>                     {
>                         // Windows Server 2012
>                         cmdLineParameters = "/Online /NoRestart
> /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services
> /featurename:MSMQ-Server";
>                     }
>
>                     string cmdLineExe;
>                     if (platformVersion.Contains("6.0.600") &&
> !Os.IsWindowsServer())
>                     {
>                         // Windows Vista
>                         cmdLineExe =
> Environment.GetFolderPath(Environment.SpecialFolder.System) +
> "\\ocsetup.exe";
>                     }
>                     else
>                     {
>                         // Windows 7 / 8 / 2008R2 / 2012
>                         var system32Directory =
> Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo
> ws),
> "system32");
>                         if (Environment.Is64BitOperatingSystem &&
> !Environment.Is64BitProcess)
>                         {
>                             // For 32-bit processes on 64-bit systems,
> %windir%\system32 folder
>                             // can only be accessed by specifying
> %windir%\sysnative folder.
>                             system32Directory =
> Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo
> ws),
> "sysnative");
>                         }
>
>                         // Windows 7 / 8 / 2008R2 / 2012
>                         cmdLineExe = system32Directory + "\\dism.exe";
>                     }
>
>                     // Install MSMQ if missing
>                     var runDismInfo = new ProcessStartInfo
>                     {
>                         UseShellExecute = true,
>                         Arguments = cmdLineParameters,
>                         FileName = cmdLineExe,
>                         WindowStyle = ProcessWindowStyle.Hidden,
>                         CreateNoWindow = true
>                     };
>
>                     // Run the external process & wait for it to finish
>                     using (var runDismProc = Process.Start(runDismInfo))
>                     {
>                         runDismProc.WaitForExit();
>                     }
>                 }
>             }
>             catch (Exception ex)
>             {
>                 WriteErrorLogInstall(session,
> "CheckToSeeIfMSMQIsInstalled
> failed: ", ex, true);
>                 if (session != null)
>                 {
>                     session.Message(
>                         InstallMessage.User +
> (int)MessageBoxIcon.Error + (int)MessageBoxButtons.OK,
>                         new Record { FormatString = productName + "
> requires Microsoft Message Queuing Service (MSMQ). Setup failed to
> install MSMQ, please go to Programs and Features and turn this feature
> on 'Microsoft Message Queue (MSMQ) Server'." });
>                 }
>
>                 return ActionResult.Failure;
>             }
>
>             return ActionResult.Success;
>         }
>
>
> private class Os
>         {
>             /// <summary>
>             /// The OS ANYSERVER.
>             /// </summary>
>             [SuppressMessage("StyleCop.CSharp.NamingRules",
> "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Reviewed.
> Suppression is OK here.")] // ReSharper disable InconsistentNaming
>             private const int OS_ANYSERVER = 29; // ReSharper restore
> InconsistentNaming
>
>             /// <summary>
>             /// Prevents a default instance of the <see cref="Os"/>
> class from being created.
>             /// </summary>
>             private Os()
>             {
>             }
>
>             /// <summary>
>             /// The is windows server.
>             /// </summary>
>             /// <returns>
>             /// The <see cref="bool"/>.
>             /// </returns>
>             public static bool IsWindowsServer()
>             {
>                 return Os.IsOS(OS_ANYSERVER);
>             }
>
>             [DllImport("shlwapi.dll", SetLastError = true, EntryPoint
> = "#437")]
>             private static extern bool IsOS(int os);
>         }
>
> Steve
>
>
> -----Original Message-----
> From: José Marques [mailto:[hidden email]]
> Sent: July-24-13 6:18 AM
> To: [hidden email]
> Subject: [WiX-users] Installing MSMQ as dependency
>
> Hello all,
>
> On the installer I'm currently developing, I need to install Microsoft
> Message Queue (MSMQ) as a dependency. Depending on Windows version, I
> need to run ocsetup.exe or sysocmgr.exe. No issues with ocsetup, my
> problem relies with sysocmgr.
> So far I've thought of two ways to do it: add an ExePackage to my
> existing bundle, or setting a custom action.
> Either way, the issues I'm currently having is:
>
> - If i do it in the bundle, i need to provide the .exe file, which I
> think it is not recommended, I have to call it. (correct me if I'm
> wrong)
> - I need to pass a file with MSMQ options as a parameter, is this possible?
> (I didn't anything remotely close with this)
>
> If there's another simple and/or correct way of installing MSMQ let me
> know as well :)
>
> Thank you for your help,
>
> José Marques
>
> ----------------------------------------------------------------------
> -------- See everything from the browser to the database with
> AppDynamics Get end-to-end visibility with application monitoring from
> AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.c
> lktrk _______________________________________________
> WiX-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
>
> This message has been marked as Public by Steven Ogilvie on July-24-13
> 9:09:47 AM.
>
> The above classification labels were added to the message by TITUS
> Message Classification. For more information visit www.titus.com.
>
>
>
>
>
>
> ----------------------------------------------------------------------
> -------- See everything from the browser to the database with
> AppDynamics Get end-to-end visibility with application monitoring from
> AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.c
> lktrk _______________________________________________
> WiX-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/wix-users

 
This message has been marked as Public by Steven Ogilvie on July-24-13 10:02:15 AM.

The above classification labels were added to the message by TITUS Message Classification. For more information visit www.titus.com.

 



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/wix-users
Reply | Threaded
Open this post in threaded view
|

Re: Installing MSMQ as dependency [P]

JoeMarks
Thank you again, I will look into C# Custom Actions.

José

On Wed, Jul 24, 2013 at 3:02 PM, Steven Ogilvie <[hidden email]>wrote:

> Classification: Public
> I have written a custom action C# DLL
>
> The custom action is called within the product.wxs:
>
> <CustomAction Id="CA_SetCHECKFORMSMQ" Property="CA_CHECKFORMSMQ"
> Value="$(var.ProductName)"/>
>     <CustomAction Id="CA_CHECKFORMSMQ" BinaryKey="BIN_CustomAction"
> DllEntry="CheckToSeeIfMSMQIsInstalled" Impersonate="no" Execute="deferred"
> Return="check"/>
>     <UI>
>       <ProgressText Action="CA_CHECKFORMSMQ">CA: Checking for Microsoft
> Message Queuing Service (MSMQ)...</ProgressText>
>     </UI>
>
> <Custom Action="CA_SetCHECKFORMSMQ" After="CostFinalize">NOT
> Installed</Custom> <Custom Action="CA_CHECKFORMSMQ"
> After="InstallInitialize">NOT Installed</Custom>
>
> -----Original Message-----
> From: José Marques [mailto:[hidden email]]
> Sent: July-24-13 9:22 AM
> To: General discussion for Windows Installer XML toolset.
> Subject: Re: [WiX-users] Installing MSMQ as dependency [P]
>
> Thank you for your reply.
> I am a bit new to Wix, as this is the first time I'm making an installer,
> where exactly do you write that code? I presume it's not straight into the
> xml, but so far I only have written XML...
>
> Best regards,
> José
>
> On Wed, Jul 24, 2013 at 2:09 PM, Steven Ogilvie <[hidden email]
> >wrote:
>
> > Classification: Public
> > I have the same requirements and ended up writing a custom action to
> > do the work for me:
> > >From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use
> > ocsetup.exe (we use MSMQ for our Server product and our Client
> > product), however Microsoft being so consistent (being sarcastic) the
> > features for MSMQ change from OS to OS :( so I ended up doing something
> like this:
> > [CustomAction]
> >         public static ActionResult CheckToSeeIfMSMQIsInstalled(Session
> > session)
> >         {
> >             var productName = string.Empty;
> >             try
> >             {
> >                 if (session == null)
> >                 {
> >                     throw new ArgumentNullException("session");
> >                 }
> >
> >                 var tempString = GetSessionProperty(session,
> > "CustomActionData", false);
> >                 var parts = tempString.Split(new[] { '|' });
> >                 productName = parts[0];
> >
> >                 var serviceExists =
> > ServiceController.GetServices().Any(s
> > => s.ServiceName == "MSMQ");
> >                 if (!serviceExists)
> >                 {
> >                     var platformVersion =
> > Environment.OSVersion.VersionString;
> >
> >                     var cmdLineParameters = string.Empty;
> >                     if (platformVersion.Contains("6.0.600") &&
> > !Os.IsWindowsServer())
> >                     {
> >                         // Windows Vista
> >                         cmdLineParameters =
> > "MSMQ-Container;MSMQ-Server /quiet /norestart";
> >                     }
> >                     else if ((platformVersion.Contains("6.1.760") &&
> > !Os.IsWindowsServer())
> >                              || (platformVersion.Contains("6.2.920")
> > &&
> > !Os.IsWindowsServer()))
> >                     {
> >                         // Windows 7 and Windows 8
> >                         cmdLineParameters = "/Online /NoRestart
> > /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server";
> >                     }
> >                     else if (platformVersion.Contains("6.1.760") &&
> > Os.IsWindowsServer())
> >                     {
> >                         // Windows Server 2008 R2
> >                         cmdLineParameters = "/Online /NoRestart
> > /Enable-Feature /featurename:MSMQ-Server";
> >                     }
> >                     else if (platformVersion.Contains("6.2.920") &&
> > Os.IsWindowsServer())
> >                     {
> >                         // Windows Server 2012
> >                         cmdLineParameters = "/Online /NoRestart
> > /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services
> > /featurename:MSMQ-Server";
> >                     }
> >
> >                     string cmdLineExe;
> >                     if (platformVersion.Contains("6.0.600") &&
> > !Os.IsWindowsServer())
> >                     {
> >                         // Windows Vista
> >                         cmdLineExe =
> > Environment.GetFolderPath(Environment.SpecialFolder.System) +
> > "\\ocsetup.exe";
> >                     }
> >                     else
> >                     {
> >                         // Windows 7 / 8 / 2008R2 / 2012
> >                         var system32Directory =
> > Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo
> > ws),
> > "system32");
> >                         if (Environment.Is64BitOperatingSystem &&
> > !Environment.Is64BitProcess)
> >                         {
> >                             // For 32-bit processes on 64-bit systems,
> > %windir%\system32 folder
> >                             // can only be accessed by specifying
> > %windir%\sysnative folder.
> >                             system32Directory =
> > Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo
> > ws),
> > "sysnative");
> >                         }
> >
> >                         // Windows 7 / 8 / 2008R2 / 2012
> >                         cmdLineExe = system32Directory + "\\dism.exe";
> >                     }
> >
> >                     // Install MSMQ if missing
> >                     var runDismInfo = new ProcessStartInfo
> >                     {
> >                         UseShellExecute = true,
> >                         Arguments = cmdLineParameters,
> >                         FileName = cmdLineExe,
> >                         WindowStyle = ProcessWindowStyle.Hidden,
> >                         CreateNoWindow = true
> >                     };
> >
> >                     // Run the external process & wait for it to finish
> >                     using (var runDismProc = Process.Start(runDismInfo))
> >                     {
> >                         runDismProc.WaitForExit();
> >                     }
> >                 }
> >             }
> >             catch (Exception ex)
> >             {
> >                 WriteErrorLogInstall(session,
> > "CheckToSeeIfMSMQIsInstalled
> > failed: ", ex, true);
> >                 if (session != null)
> >                 {
> >                     session.Message(
> >                         InstallMessage.User +
> > (int)MessageBoxIcon.Error + (int)MessageBoxButtons.OK,
> >                         new Record { FormatString = productName + "
> > requires Microsoft Message Queuing Service (MSMQ). Setup failed to
> > install MSMQ, please go to Programs and Features and turn this feature
> > on 'Microsoft Message Queue (MSMQ) Server'." });
> >                 }
> >
> >                 return ActionResult.Failure;
> >             }
> >
> >             return ActionResult.Success;
> >         }
> >
> >
> > private class Os
> >         {
> >             /// <summary>
> >             /// The OS ANYSERVER.
> >             /// </summary>
> >             [SuppressMessage("StyleCop.CSharp.NamingRules",
> > "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Reviewed.
> > Suppression is OK here.")] // ReSharper disable InconsistentNaming
> >             private const int OS_ANYSERVER = 29; // ReSharper restore
> > InconsistentNaming
> >
> >             /// <summary>
> >             /// Prevents a default instance of the <see cref="Os"/>
> > class from being created.
> >             /// </summary>
> >             private Os()
> >             {
> >             }
> >
> >             /// <summary>
> >             /// The is windows server.
> >             /// </summary>
> >             /// <returns>
> >             /// The <see cref="bool"/>.
> >             /// </returns>
> >             public static bool IsWindowsServer()
> >             {
> >                 return Os.IsOS(OS_ANYSERVER);
> >             }
> >
> >             [DllImport("shlwapi.dll", SetLastError = true, EntryPoint
> > = "#437")]
> >             private static extern bool IsOS(int os);
> >         }
> >
> > Steve
> >
> >
> > -----Original Message-----
> > From: José Marques [mailto:[hidden email]]
> > Sent: July-24-13 6:18 AM
> > To: [hidden email]
> > Subject: [WiX-users] Installing MSMQ as dependency
> >
> > Hello all,
> >
> > On the installer I'm currently developing, I need to install Microsoft
> > Message Queue (MSMQ) as a dependency. Depending on Windows version, I
> > need to run ocsetup.exe or sysocmgr.exe. No issues with ocsetup, my
> > problem relies with sysocmgr.
> > So far I've thought of two ways to do it: add an ExePackage to my
> > existing bundle, or setting a custom action.
> > Either way, the issues I'm currently having is:
> >
> > - If i do it in the bundle, i need to provide the .exe file, which I
> > think it is not recommended, I have to call it. (correct me if I'm
> > wrong)
> > - I need to pass a file with MSMQ options as a parameter, is this
> possible?
> > (I didn't anything remotely close with this)
> >
> > If there's another simple and/or correct way of installing MSMQ let me
> > know as well :)
> >
> > Thank you for your help,
> >
> > José Marques
> >
> > ----------------------------------------------------------------------
> > -------- See everything from the browser to the database with
> > AppDynamics Get end-to-end visibility with application monitoring from
> > AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
> > Start your free trial of AppDynamics Pro today!
> > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.c
> > lktrk _______________________________________________
> > WiX-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/wix-users
> >
> >
> > This message has been marked as Public by Steven Ogilvie on July-24-13
> > 9:09:47 AM.
> >
> > The above classification labels were added to the message by TITUS
> > Message Classification. For more information visit www.titus.com.
> >
> >
> >
> >
> >
> >
> > ----------------------------------------------------------------------
> > -------- See everything from the browser to the database with
> > AppDynamics Get end-to-end visibility with application monitoring from
> > AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
> > Start your free trial of AppDynamics Pro today!
> > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.c
> > lktrk _______________________________________________
> > WiX-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/wix-users
> >
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics Get
> end-to-end visibility with application monitoring from AppDynamics Isolate
> bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> WiX-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
>
> This message has been marked as Public by Steven Ogilvie on July-24-13
> 10:02:15 AM.
>
> The above classification labels were added to the message by TITUS Message
> Classification. For more information visit www.titus.com.
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> WiX-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/wix-users