Example #1
0
        /// <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);
        }
Example #2
0
        /// <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);
        }