I wrote my own installer UI with burn bootstrapper. It has a WPF frontend. I have an EXE with 3 MSI pacakges included. So when I try to install it in a disk with not enough space, how can I show an error message dialog in my installer UI? Is there a callback using which I can find if there is enough disk space? Please advice.
Asked
Active
Viewed 844 times
1 Answers
2
I'm looking at doing the same.
The secret is to read and parse the BootstrapperApplicationData.xml. You can then use InstalledSize attribute from the WixPackageProperties element. This link Getting Display Name from PackageID shows you how do read that file at runtime. Note that you'll have to add in the InstalledSize to the relevant structure.
It'll be up to you to go and check the disk space compared to the sum of those numbers and flag that up to the user prior to install.
This is a copy/paste of the some of my code:
using System.Collections.ObjectModel;
using System.Xml.Serialization;
public class PackageInfo
{
[XmlAttribute("Package")]
public string Id { get; set; }
[XmlAttribute("DisplayName")]
public string DisplayName { get; set; }
[XmlAttribute("Description")]
public string Description { get; set; }
[XmlAttribute("InstalledSize")]
public int InstalledSize { get; set; }
}
[XmlRoot("BootstrapperApplicationData", IsNullable = false, Namespace = "http://schemas.microsoft.com/wix/2010/BootstrapperApplicationData")]
public class BundleInfo
{
[XmlElement("WixPackageProperties")]
public Collection<PackageInfo> Packages { get; set; } = new Collection<PackageInfo>();
}
public static class BundleInfoLoader
{
private static readonly string bootstrapperApplicationData = "BootstrapperApplicationData.xml";
public static BundleInfo Load()
{
var bundleFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var path = Path.Combine(bundleFolder, bootstrapperApplicationData);
var xmlSerializer = new XmlSerializer(typeof(BundleInfo));
BundleInfo result;
using (var fileStream = new FileStream(path, FileMode.Open))
{
var xmlReader = XmlReader.Create(fileStream);
result = (BundleInfo)xmlSerializer.Deserialize(xmlReader);
}
return result;
}
}
-
hey mate, where is this XML located at? I don't find it in my bin/release directory – AnOldSoul Jul 09 '16 at 10:47
-
The load method finds it. It will load the XML from the assemblies executing location. When the burn .exe runs, it creates a subfolder in your temp folder with a GUID. Inside that folder it creates an additional folder called '.ba'. In that folder you'll find your C# library. the bootstrapper config, a bunch of supporting files and the BootstrapperApplicationData.xml file, which is what I am loading in the code above. – intinit Jul 19 '16 at 16:29