【问题标题】:Wix bootstrapper conditional installationWix 引导程序有条件安装
【发布时间】:2021-02-10 12:22:32
【问题描述】:

我创建了一个带有 2 个复选框的用户界面的 wix 引导程序应用程序。用户可以选择安装什么。这是我的引导应用程序的一部分:

 <MsiPackage 
        InstallCondition="ClientCondition"
        DisplayInternalUI='yes'
        Visible="yes"
        SourceFile="D:\Project\FirstInstaller.msi"
      />
      <MsiPackage
        InstallCondition="ServerCondition"
        DisplayInternalUI='yes'
        Visible="yes"
        SourceFile="D:\Project\SecondInstaller.msi"
      />

问题: 例如,我已经安装了 FirstInstaller,我正在尝试安装第二个。由于错误情况,我的 FirstInstaller 将被卸载。但这不是我所期望的。如何解决此问题并为链中的 Msi 包设置一些“忽略”值?

【问题讨论】:

    标签: wix bootstrapper


    【解决方案1】:

    我不知道您的引导程序是用哪种语言编写的,但是,作为选项,您可以通过 cmd 和 msiexec 命令直接从您的代码中控制您的 msi 安装。

    C# 的代码示例:

            var command = @"/c msiexec /i c:\path\to\package.msi";
            //for silent: /quiet /qn /norestart 
            //for log: /log c:\path\to\install.log 
            //with properties: PROPERTY1=value1 PROPERTY2=value2";
            var output = string.Empty;
            using (var p = new Process())
            {
                p.StartInfo = new ProcessStartInfo()
                {
                    FileName = "cmd.exe",
                    Arguments = command,
                    UseShellExecute = false,
                    RedirectStandardError = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow = true,
                };
                p.Start();
                while (!p.StandardOutput.EndOfStream)
                {
                    output += $"{p.StandardOutput.ReadLine()}{Environment.NewLine}";
                }
                p.WaitForExit();
                if (p.ExitCode != 0)
                {
                    throw new Exception($"{p.ExitCode}:{ p.StandardError.ReadToEnd()}");
                }
                Console.WriteLine(output);
                Console.ReadKey();
            }
    

    【讨论】:

    • 嗨,ba-a-anton,谢谢你的回答。但是您的解决方案存在问题,在这种情况下,我必须将安装程序和另一个应用程序交付给客户来管理它们。
    • 好吧,在某些情况下,引导程序已经是“另一个应用程序”——您可以编写具有自己的 UI 和代码隐藏的自定义引导程序。想法是将我的示例添加到该代码隐藏中。我认为这是你的情况,但现在看来你使用的是标准的。如果您需要更多信息,请参阅this thread。这是一个有点令人困惑的话题,在你的情况下可能是开销,特别是如果你需要 C# 引导程序。但是,至少,你有一个选择)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多