wix - Wix 引导程序有条件安装
问题描述
我创建了一个带有 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();
}
推荐阅读
- c++ - 试图学习指针,为什么要使用它们而不是 &?
- unix - 如何在 Unix 中删除核心文件?
- android - android 和 REST API - 管理用户和对服务器的请求的架构
- python - argparse 需要带有可变参数的选项?
- websocket - 如何修复“AttributeError: 'DistributeHandler' 对象没有属性 'group'”?
- r - 如何删除维恩图边框?
- android - android Spinner:在 onItemSelected 视图中为空
- reactjs - React hooks fetch 不会停止获取
- c# - CefSharp 检测是否正在播放音频
- node.js - 使用ajax调用进行数据库操作后的节点渲染页面