public static BundleInfo ParseBundleFromXml(XPathNavigator root) { BundleInfo bundle = new BundleInfo(); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); XPathNavigator bundleNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:WixBundleProperties", namespaceManager); if (bundleNode == null) { throw new Exception("Failed to select bundle information."); } bool?perMachine = BootstrapperApplicationData.GetYesNoAttribute(bundleNode, "PerMachine"); if (perMachine.HasValue) { bundle.PerMachine = perMachine.Value; } bundle.Name = BootstrapperApplicationData.GetAttribute(bundleNode, "DisplayName"); bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable"); foreach (PackageInfo package in PackageInfo.ParsePackagesFromXml(root)) { bundle.Packages.Add(package.Id, package); } return(bundle); }
public static IEnumerable <PackageInfo> ParsePackagesFromXml(XPathNavigator root) { XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); foreach (XPathNavigator node in nodes) { PackageInfo package = new PackageInfo(); string id = BootstrapperApplicationData.GetAttribute(node, "Package"); if (id == null) { throw new Exception("Failed to get package identifier for package."); } package.Id = id; package.DisplayName = BootstrapperApplicationData.GetAttribute(node, "DisplayName"); package.Description = BootstrapperApplicationData.GetAttribute(node, "Description"); PackageType?packageType = GetPackageTypeAttribute(node, "PackageType"); if (!packageType.HasValue) { throw new Exception("Failed to get package type for package."); } package.Type = packageType.Value; bool?permanent = BootstrapperApplicationData.GetYesNoAttribute(node, "Permanent"); if (!permanent.HasValue) { throw new Exception("Failed to get permanent settings for package."); } package.Permanent = permanent.Value; bool?vital = BootstrapperApplicationData.GetYesNoAttribute(node, "Vital"); if (!vital.HasValue) { throw new Exception("Failed to get vital setting for package."); } package.Vital = vital.Value; bool?displayInternalUI = BootstrapperApplicationData.GetYesNoAttribute(node, "DisplayInternalUI"); package.DisplayInternalUI = displayInternalUI.HasValue && displayInternalUI.Value; package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); package.Version = BootstrapperApplicationData.GetAttribute(node, "Version"); package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); yield return(package); } }