/// <summary> /// Parses BA manifest from the given <see cref="XPathNavigator"/>. /// </summary> /// <param name="root">The root of the BA manifest.</param> /// <returns></returns> public static IBundleInfo 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"); bundle.Packages = PackageInfo.ParsePackagesFromXml(root); return(bundle); }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="attributeName"></param> /// <returns></returns> public static PackageType?GetPackageTypeAttribute(XPathNavigator node, string attributeName) { string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); if (attributeValue == null) { return(null); } if (attributeValue.Equals("Exe", StringComparison.InvariantCulture)) { return(PackageType.Exe); } else if (attributeValue.Equals("Msi", StringComparison.InvariantCulture)) { return(PackageType.Msi); } else if (attributeValue.Equals("Msp", StringComparison.InvariantCulture)) { return(PackageType.Msp); } else if (attributeValue.Equals("Msu", StringComparison.InvariantCulture)) { return(PackageType.Msu); } else { return(PackageType.Unknown); } }
/// <summary> /// /// </summary> /// <param name="root"></param> /// <returns></returns> public static IDictionary <string, IPackageInfo> ParsePackagesFromXml(XPathNavigator root) { var packagesById = new Dictionary <string, IPackageInfo>(); 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) { var 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; package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); package.Version = BootstrapperApplicationData.GetAttribute(node, "Version"); package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); packagesById.Add(package.Id, package); } ParseBalPackageInfoFromXml(root, namespaceManager, packagesById); return(packagesById); }
internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespaceManager namespaceManager, Dictionary <string, IPackageInfo> packagesById) { XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixBalPackageInfo", namespaceManager); foreach (XPathNavigator node in nodes) { string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); if (id == null) { throw new Exception("Failed to get package identifier for WixBalPackageInfo."); } if (!packagesById.TryGetValue(id, out var ipackage)) { throw new Exception(string.Format("Failed to find package specified in WixBalPackageInfo: {0}", id)); } var package = (PackageInfo)ipackage; package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); } nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", namespaceManager); foreach (XPathNavigator node in nodes) { string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); if (id == null) { throw new Exception("Failed to get package identifier for WixMbaPrereqInformation."); } if (!packagesById.TryGetValue(id, out var ipackage)) { throw new Exception(string.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); } var package = (PackageInfo)ipackage; package.PrereqPackage = true; package.PrereqLicenseFile = BootstrapperApplicationData.GetAttribute(node, "LicenseFile"); package.PrereqLicenseUrl = BootstrapperApplicationData.GetAttribute(node, "LicenseUrl"); } }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="attributeName"></param> /// <returns></returns> public static BOOTSTRAPPER_CACHE_TYPE?GetCacheTypeAttribute(XPathNavigator node, string attributeName) { string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); if (attributeValue == null) { return(null); } if (attributeValue.Equals("keep", StringComparison.InvariantCulture)) { return(BOOTSTRAPPER_CACHE_TYPE.Keep); } else if (attributeValue.Equals("force", StringComparison.InvariantCulture)) { return(BOOTSTRAPPER_CACHE_TYPE.Force); } else { return(BOOTSTRAPPER_CACHE_TYPE.Remove); } }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="attributeName"></param> /// <returns></returns> public static CacheType?GetCacheTypeAttribute(XPathNavigator node, string attributeName) { string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); if (attributeValue == null) { return(null); } if (attributeValue.Equals("yes", StringComparison.InvariantCulture)) { return(CacheType.Yes); } else if (attributeValue.Equals("always", StringComparison.InvariantCulture)) { return(CacheType.Always); } else { return(CacheType.No); } }