2

我正在使用 Wix 3.6,我想为我的先决条件和安装期间需要调用的某些 exe 实现一个引导程序。

我知道 Burn 存在并且已经玩过它,尽管我不喜欢它保持的对话框,即使你显示 MSI 对话框集。

我目前使用 C++ 自定义操作安装了我的先决条件和 exe 文件,但我希望我的用户有更好的安装过程并遵循 Windows Installer 最佳实践指南。

有谁知道制作一个显示 MSI 对话框并有任何示例的引导程序?

4

1 回答 1

0

首先,如果您想遵循安装程序的最佳实践,我不建议您使用自定义操作安装先决条件。

说到你的问题,这是我在 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.

于 2013-01-10T17:21:01.483 回答