问题描述
我创建了一个带有 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 包设置一些“忽略”值?
解决方法
我不知道您的引导程序是用哪种语言编写的,但是,作为选项,您可以通过 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();
}