I wrote a WiX custom MBA that I have been using which embeds all of the setup packages (msis, cabs and exes) I need for my installation. However I would now like to make a lightweight web bootstrapper which will download the packages that need to be installed. I thought you would get that for free with the underlying WiX bootstrapper engine, but I guess I was wrong.
I tried subscribing to the ResolveSource event to get a package's download url and download it to the local source location, but it seems like at that point it's too late in the process as my installation fails with an error "Failed to resolve source for file: " (even though the download is successful).
Sample of what I tried:
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;
}
}
}
Thanks to Rob Mensching answering this on the wix-users mailing list:
I edited my code as follows:
Setting the result to
Result.Download
instructs the bootstrapper engine to download the package. No need to try to download the file myself.