src/WingetCreateCore/Common/PackageParser.cs
/// <summary>
/// Parses the package for relevant metadata and and updates the metadata of the provided installer node.
/// </summary>
/// <param name="installer">Installer node.</param>
/// <param name="path">Path to package file.</param>
/// <param name="url">Installer url.</param>
/// <returns>Boolean indicating whether the package parse was successful.</returns>
Parses the package for relevant metadata and and updates the metadata of the provided installer node.
Parses the package for relevant metadata and and updates the metadata of the provided installer node .
public static bool ParsePackageAndUpdateInstallerNode(Installer installer, string path, string url)
        {
            List<Installer> newInstallers = new List<Installer>();
            bool parseResult = ParseExeInstallerType(path, installer, newInstallers) ||
                ParseMsix(path, installer, null, newInstallers) ||
                ParseMsi(path, installer, null, newInstallers);
            if (!parseResult || !newInstallers.Any())
            {
                return false;
            }
            Installer newInstaller = newInstallers.First();
            if (newInstallers.Count > 1)
            {
                newInstaller.Architecture = installer.Architecture;
            }
            else
            {
                newInstaller.Architecture = GetArchFromUrl(url) ?? GetMachineType(path)?.ToString().ToEnumOrDefault<InstallerArchitecture>() ?? installer.Architecture;
            }
            newInstaller.InstallerUrl = url;
            newInstaller.InstallerSha256 = GetFileHash(path);
            UpdateInstallerMetadata(installer, newInstallers.First());
            return true;
        }
public static bool ParsePackageAndUpdateInstallerNode ( Installer installer , string path , string url ) { List < Installer > newInstallers = new List < Installer > ( ) ; bool parseResult = ParseExeInstallerType ( path , installer , newInstallers ) || ParseMsix ( path , installer , null , newInstallers ) || ParseMsi ( path , installer , null , newInstallers ) ; if ( ! parseResult || ! newInstallers . Any ( ) ) { return false ; } Installer newInstaller = newInstallers . First ( ) ; if ( newInstallers . Count > 1 ) { newInstaller . Architecture = installer . Architecture ; } else { newInstaller . Architecture = GetArchFromUrl ( url ) ?? GetMachineType ( path ) ? . ToString ( ) . ToEnumOrDefault < InstallerArchitecture > ( ) ?? installer . Architecture ; } newInstaller . InstallerUrl = url ; newInstaller . InstallerSha256 = GetFileHash ( path ) ; UpdateInstallerMetadata ( installer , newInstallers . First ( ) ) ; return true ; }
Parses the package for relevant metadata and and updates the metadata of the provided installer node.
Parses the package for relevant metadata and and updates the metadata of the provided installer node .
// For multiple installers in an AppxBundle, use the existing architecture to avoid matching conflicts. // For a single installer, detect the architecture. If no architecture is detected, default to architecture from existing manifest.
Boolean indicating whether the package parse was successful.
Boolean indicating whether the package parse was successful .
installer
Installer
None
path
string
Path to package file.
Path to package file .
url
string
None