src/WingetCreateCore/Common/PackageParser.cs
/// <summary>
/// Update InstallerManifest's Installer nodes using the provided list of InstallerMetadata objects.
/// </summary>
/// <param name="installerMetadataList">List of <see cref="InstallerMetadata"/>.</param>
/// <param name="installerManifest"><see cref="InstallerManifest"/> to update.</param>
Update InstallerManifest's Installer nodes using the provided list of InstallerMetadata objects.
Update InstallerManifest ' s Installer nodes using the provided list of InstallerMetadata objects .
public static void UpdateInstallerNodesAsync(List<InstallerMetadata> installerMetadataList, InstallerManifest installerManifest)
        {
            var existingInstallers = new List<Installer>(installerManifest.Installers);
            List<Installer> unmatchedInstallers = new List<Installer>();
            List<Installer> multipleMatchedInstallers = new List<Installer>();
            List<string> parseFailedInstallerUrls = new List<string>();
            foreach (var installerMetadata in installerMetadataList)
            {
                if (!ParsePackageAndGenerateInstallerNodes(installerMetadata, null))
                {
                    parseFailedInstallerUrls.Add(installerMetadata.InstallerUrl);
                }
            }
            int numOfNewInstallers = installerMetadataList.Sum(x => x.NewInstallers.Count);
            if (numOfNewInstallers != existingInstallers.Count)
            {
                throw new InvalidOperationException();
            }
            if (parseFailedInstallerUrls.Any())
            {
                throw new ParsePackageException(parseFailedInstallerUrls);
            }
            Dictionary<Installer, Installer> installerMatchDict = new Dictionary<Installer, Installer>();
            foreach (var installerUpdate in installerMetadataList)
            {
                foreach (var newInstaller in installerUpdate.NewInstallers)
                {
                    Installer existingInstallerMatch = FindInstallerMatch(
                        newInstaller,
                        existingInstallers,
                        installerManifest,
                        installerUpdate,
                        ref unmatchedInstallers,
                        ref multipleMatchedInstallers);
                    if (existingInstallerMatch != null)
                    {
                        installerMatchDict.Add(existingInstallerMatch, newInstaller);
                        existingInstallers.Remove(existingInstallerMatch);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if (unmatchedInstallers.Any() || multipleMatchedInstallers.Any())
            {
                bool isArchitectureOverride = installerMetadataList.Any(x => x.OverrideArchitecture.HasValue);
                throw new InstallerMatchException(multipleMatchedInstallers, unmatchedInstallers, isArchitectureOverride);
            }
            else
            {
                foreach (var existingInstaller in installerMatchDict.Keys)
                {
                    UpdateInstallerMetadata(existingInstaller, installerMatchDict[existingInstaller]);
                }
            }
        }
public static void UpdateInstallerNodesAsync ( List < InstallerMetadata > installerMetadataList , InstallerManifest installerManifest ) { var existingInstallers = new List < Installer > ( installerManifest . Installers ) ; List < Installer > unmatchedInstallers = new List < Installer > ( ) ; List < Installer > multipleMatchedInstallers = new List < Installer > ( ) ; List < string > parseFailedInstallerUrls = new List < string > ( ) ; foreach ( var installerMetadata in installerMetadataList ) { if ( ! ParsePackageAndGenerateInstallerNodes ( installerMetadata , null ) ) { parseFailedInstallerUrls . Add ( installerMetadata . InstallerUrl ) ; } } int numOfNewInstallers = installerMetadataList . Sum ( x => x . NewInstallers . Count ) ; if ( numOfNewInstallers != existingInstallers . Count ) { throw new InvalidOperationException ( ) ; } if ( parseFailedInstallerUrls . Any ( ) ) { throw new ParsePackageException ( parseFailedInstallerUrls ) ; } Dictionary < Installer , Installer > installerMatchDict = new Dictionary < Installer , Installer > ( ) ; foreach ( var installerUpdate in installerMetadataList ) { foreach ( var newInstaller in installerUpdate . NewInstallers ) { Installer existingInstallerMatch = FindInstallerMatch ( newInstaller , existingInstallers , installerManifest , installerUpdate , ref unmatchedInstallers , ref multipleMatchedInstallers ) ; if ( existingInstallerMatch != null ) { installerMatchDict . Add ( existingInstallerMatch , newInstaller ) ; existingInstallers . Remove ( existingInstallerMatch ) ; } else { continue ; } } } if ( unmatchedInstallers . Any ( ) || multipleMatchedInstallers . Any ( ) ) { bool isArchitectureOverride = installerMetadataList . Any ( x => x . OverrideArchitecture . HasValue ) ; throw new InstallerMatchException ( multipleMatchedInstallers , unmatchedInstallers , isArchitectureOverride ) ; } else { foreach ( var existingInstaller in installerMatchDict . Keys ) { UpdateInstallerMetadata ( existingInstaller , installerMatchDict [ existingInstaller ] ) ; } } }
Update InstallerManifest's Installer nodes using the provided list of InstallerMetadata objects.
Update InstallerManifest ' s Installer nodes using the provided list of InstallerMetadata objects .
// We only allow updating manifests with the same package count // Update previous installers with parsed data from downloaded packages // if the installerUpdate does not have a binary or url architecture specified, then just use what is specified in the installer. // If a match is found, add match to dictionary and remove for list of existingInstallers
installerMetadataList
List<InstallerMetadata>
List of .
List of .
installerManifest
InstallerManifest
None