2
votes

I'm using Wix 3.6 and I would like to implement a bootstrapper for my prerequisites and for certain exe's that I need to call during my install.

I know Burn exists and have played around with it, although I don't like the dialog it keeps up even if you show the MSI dialog set.

I currently have my prerequisites and exe files installing with C++ custom actions but I would like my user to have a better installation process and also follow the Windows Installer Best Practices guidelines.

Does anyone know to to make a bootstrapper that shows the MSI dialogs and have any examples?

1

1 Answers

0
votes

At first, if you want to follow installer best practices, I wouldn't recommend installing prerequisites using custom actions.

Speaking about your question, here is my implementation of custom bootstrapper in C#:

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SetupBootstrapper
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            var currentDir = AppDomain.CurrentDomain.BaseDirectory;
            var parameters = string.Empty;
            if (args.Length > 0)
            {
                var sb = new StringBuilder();
                foreach (var arg in args)
                {
                    if (arg != "/i" && arg != "/x" && arg != "/u")
                    {
                        sb.Append(" ");
                        sb.Append(arg);
                    }
                }
                parameters = sb.ToString();
            }

            bool isUninstall = args.Contains("/x") || args.Contains("/u");

            string msiPath = Path.Combine(currentDir, "MyMsiName.msi");

            if(!File.Exists(msiPath))
            {
                MessageBox.Show(string.Format("File '{0}' doesn't exist", msiPath), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string installerParameters = (isUninstall ? "/x" : "/i ") + "\"" + msiPath + "\"" + parameters;

            var installerProcess = new Process { StartInfo = new ProcessStartInfo("msiexec", installerParameters) { Verb = "runas" } };

            installerProcess.Start();
            installerProcess.WaitForExit();
        }
    }
}

To make it ask for elevated permissions I add application manifest file into project with desired access level.

The drawback of implementing bootstrapper in .NET is of course that you can't adequately process situation when .NET is a prerequisite itself and may be absent on target machine.