我写了一个我一直在使用的 WiX 自定义 MBA,它嵌入了我安装所需的所有安装包(msis、cab 和 exe)。但是我现在想制作一个轻量级的网络 Bootstrap ,它将下载需要安装的包。我以为您可以通过底层的 WiX Bootstrap 引擎免费获得它,但我想我错了。
我尝试订阅 ResolveSource 事件以获取包的下载 URL 并将其下载到本地源位置,但似乎此时为时已晚,因为我的安装失败并出现错误“无法解析源” for file: "(即使下载成功)。
我尝试过的示例:
private void OnResolveSource(object sender, ResolveSourceEventArgs e)
{
string localSource = e.LocalSource;
string downloadSource = e.DownloadSource;
if (!File.Exists(localSource) && !string.IsNullOrEmpty(downloadSource))
{
try
{
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(e.DownloadSource, e.LocalSource);
}
}
catch (ArgumentNullException ex)
{
e.Result = Result.Error;
}
catch (WebException ex)
{
e.Result = Result.Error;
}
}
}
最佳答案
感谢 Rob Mensching 在 wix-users 邮件列表上回答这个问题:
Make sure your packages of URLs provided (authored is easiest but you can programmatically set them all) then return IDDOWNLOAD from the ResolveSource call.
我按如下方式编辑了我的代码:
private void OnResolveSource(object sender, ResolveSourceEventArgs e)
{
if (!File.Exists(e.LocalSource) && !string.IsNullOrEmpty(e.DownloadSource))
e.Result = Result.Download;
}
将结果设置为 Result.Download
指示 Bootstrap 引擎下载包。无需尝试自己下载文件。
关于c# - 在 WiX 自定义托管 Bootstrap 应用程序中下载安装包的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14627507/