示例#1
0
        /// <summary>
        /// Reads the manifest and populates the ExternalAppxPackagesRelativePaths and InternalAppxPackagesRelativePaths lists.
        /// </summary>
        private void PopulateChildAppxPackages()
        {
            IAppxBundleManifestPackageInfoEnumerator subPackagesEnumerator = this.manifestReader.GetPackageInfoItems();

            while (subPackagesEnumerator.GetHasCurrent())
            {
                IAppxBundleManifestPackageInfo subPackageInfo = subPackagesEnumerator.GetCurrent();

                // If the package is not contained within the bundle, the corresponding package element in the bundle manifest
                // would not have an offset field. In such a case and only in that case, the AppxPackaging APIs would return 0
                // when retrieving the offset.
                if (subPackageInfo.GetOffset() == 0)
                {
                    this.ExternalAppxPackages.Add(new ExternalPackageReference(
                                                      this,
                                                      subPackageInfo.GetPackageId().GetPackageFullName(),
                                                      subPackageInfo.GetFileName(),
                                                      isOptional: false));
                }
                else
                {
                    this.InternalAppxPackagesRelativePaths.Add(subPackageInfo.GetFileName());
                }

                subPackagesEnumerator.MoveNext();
            }
        }
示例#2
0
        /// <summary>
        /// Reads the manifest and populates the OptionalAppxBundles and OptionalAppxPackages lists.
        /// </summary>
        private void PopulateOptionalAppxPackagesAndBundles()
        {
            this.optionalAppxPackages = new List <ExternalPackageReference>();
            this.optionalAppxBundles  = new List <ExternalPackageReference>();

            IAppxBundleManifestReader2 bundleManifestReader2 = (IAppxBundleManifestReader2)this.manifestReader;

            // Iterate over all OptionalBundle elements in the manifest
            IAppxBundleManifestOptionalBundleInfoEnumerator optionalBundlesEnumerator = bundleManifestReader2.GetOptionalBundles();

            while (optionalBundlesEnumerator.GetHasCurrent())
            {
                IAppxBundleManifestOptionalBundleInfo optionalBundleInfo = optionalBundlesEnumerator.GetCurrent();

                if (optionalBundleInfo.GetFileName() != null)
                {
                    // If the file name of the OptionalBundle is not null, it points to a physical optional package bundle, in which
                    // case we recursively create the bundle info for the optional bundle.
                    this.OptionalAppxBundles.Add(new ExternalPackageReference(
                                                     this,
                                                     optionalBundleInfo.GetPackageId().GetPackageFullName(),
                                                     optionalBundleInfo.GetFileName(),
                                                     isOptional: true));
                }
                else
                {
                    // Otherwise, the PackageInfo child elements of the OptionalBundle element point to the optional msix packages.
                    IAppxBundleManifestPackageInfoEnumerator optionalPackagesEnumerator = optionalBundleInfo.GetPackageInfoItems();

                    while (optionalPackagesEnumerator.GetHasCurrent())
                    {
                        IAppxBundleManifestPackageInfo optionalPackageInfo = optionalPackagesEnumerator.GetCurrent();
                        this.OptionalAppxPackages.Add(new ExternalPackageReference(
                                                          this,
                                                          optionalPackageInfo.GetPackageId().GetPackageFullName(),
                                                          optionalPackageInfo.GetFileName(),
                                                          isOptional: true));

                        optionalPackagesEnumerator.MoveNext();
                    }
                }

                optionalBundlesEnumerator.MoveNext();
            }
        }
示例#3
0
        /// <summary>
        /// Reads the manifest and populates the ExternalAppxPackagesRelativePaths and InternalAppxPackagesRelativePaths lists.
        /// </summary>
        private void PopulateChildAppxPackages()
        {
            IAppxBundleManifestPackageInfoEnumerator subPackagesEnumerator = this.manifestReader.GetPackageInfoItems();

            while (subPackagesEnumerator.GetHasCurrent())
            {
                IAppxBundleManifestPackageInfo subPackageInfo = subPackagesEnumerator.GetCurrent();
                IAppxManifestPackageId         subPackageId   = subPackageInfo.GetPackageId();
                string filePath = subPackageInfo.GetFileName();

                // If the package is not contained within the bundle, the corresponding package element in the bundle manifest
                // would not have an offset field. In such a case and only in that case, the AppxPackaging APIs would return 0
                // when retrieving the offset.
                if (subPackageInfo.GetOffset() == 0)
                {
                    this.ExternalAppxPackages.Add(new ExternalPackageReference(
                                                      this,
                                                      subPackageId.GetPackageFullName(),
                                                      filePath,
                                                      isOptional: false));
                }
                else
                {
                    var childPackageMetadata = new ChildPackageMetadata(
                        this,
                        subPackageId.GetPackageFullName(),
                        filePath,
                        subPackageInfo.GetPackageType(),
                        subPackageInfo.GetSize(),
                        subPackageId.GetVersion(),
                        subPackageId.GetResourceId());

                    this.ChildAppxPackages.Add(childPackageMetadata);

#pragma warning disable CS0612 // Type or member is obsolete
                    this.InternalAppxPackagesRelativePaths.Add(filePath);
#pragma warning restore CS0612 // Type or member is obsolete
                }

                subPackagesEnumerator.MoveNext();
            }
        }