src/WingetCreateCore/Common/PackageParser.cs
/// <summary>
/// Parses a package for relevant metadata and generates a new installer node for each installer file (MSIX can have multiple installers).
/// </summary>
/// <param name="installerMetadata">Helper class for storing an installer's metadata information.</param>
/// <param name="manifests">Manifests object model.</param>
/// <returns>Boolean value indicating whether the function was successful or not.</returns>
Parses a package for relevant metadata and generates a new installer node for each installer file (MSIX can have multiple installers).
Parses a package for relevant metadata and generates a new installer node for each installer file ( MSIX can have multiple installers ) .
private static bool ParsePackageAndGenerateInstallerNodes(InstallerMetadata installerMetadata, Manifests manifests)
        {
            var url = installerMetadata.InstallerUrl;
            var path = installerMetadata.PackageFile;
            var newInstallers = installerMetadata.NewInstallers;
            var baseInstaller = new Installer();
            baseInstaller.InstallerUrl = url;
            baseInstaller.InstallerSha256 = GetFileHash(path);
            baseInstaller.Architecture = GetMachineType(path)?.ToString().ToEnumOrDefault<InstallerArchitecture>() ?? InstallerArchitecture.Neutral;
            bool parseMsixResult = false;
            bool parseResult = ParseExeInstallerType(path, baseInstaller, newInstallers) ||
                (parseMsixResult = ParseMsix(path, baseInstaller, manifests, newInstallers)) ||
                ParseMsi(path, baseInstaller, manifests, newInstallers);
            if (!parseMsixResult)
            {
                var urlArchitecture = installerMetadata.UrlArchitecture = GetArchFromUrl(baseInstaller.InstallerUrl);
                installerMetadata.UrlArchitecture = GetArchFromUrl(baseInstaller.InstallerUrl);
                installerMetadata.BinaryArchitecture = baseInstaller.Architecture;
                var overrideArch = installerMetadata.OverrideArchitecture;
                if (overrideArch.HasValue)
                {
                    baseInstaller.Architecture = overrideArch.Value;
                }
                else if (urlArchitecture.HasValue)
                {
                    baseInstaller.Architecture = urlArchitecture.Value;
                }
            }
            return parseResult;
        }
private static bool ParsePackageAndGenerateInstallerNodes ( InstallerMetadata installerMetadata , Manifests manifests ) { var url = installerMetadata . InstallerUrl ; var path = installerMetadata . PackageFile ; var newInstallers = installerMetadata . NewInstallers ; var baseInstaller = new Installer ( ) ; baseInstaller . InstallerUrl = url ; baseInstaller . InstallerSha256 = GetFileHash ( path ) ; baseInstaller . Architecture = GetMachineType ( path ) ? . ToString ( ) . ToEnumOrDefault < InstallerArchitecture > ( ) ?? InstallerArchitecture . Neutral ; bool parseMsixResult = false ; bool parseResult = ParseExeInstallerType ( path , baseInstaller , newInstallers ) || ( parseMsixResult = ParseMsix ( path , baseInstaller , manifests , newInstallers ) ) || ParseMsi ( path , baseInstaller , manifests , newInstallers ) ; if ( ! parseMsixResult ) { var urlArchitecture = installerMetadata . UrlArchitecture = GetArchFromUrl ( baseInstaller . InstallerUrl ) ; installerMetadata . UrlArchitecture = GetArchFromUrl ( baseInstaller . InstallerUrl ) ; installerMetadata . BinaryArchitecture = baseInstaller . Architecture ; var overrideArch = installerMetadata . OverrideArchitecture ; if ( overrideArch . HasValue ) { baseInstaller . Architecture = overrideArch . Value ; } else if ( urlArchitecture . HasValue ) { baseInstaller . Architecture = urlArchitecture . Value ; } } return parseResult ; }
Parses a package for relevant metadata and generates a new installer node for each installer file (MSIX can have multiple installers).
Parses a package for relevant metadata and generates a new installer node for each installer file ( MSIX can have multiple installers ) .
// Only capture architecture if installer is non-msix as the architecture for msix installers is deterministic
Boolean value indicating whether the function was successful or not.
Boolean value indicating whether the function was successful or not .
installerMetadata
InstallerMetadata
Helper class for storing an installer's metadata information.
Helper class for storing an installer ' s metadata information .
manifests
Manifests
Manifests object model.
Manifests object model .