/// <inheritdoc cref="PackageBase.GetCannotBeInstalledReason"/> public static string GetCannotBeInstalledReason(FileInfo installerFile, bool isBundle) { Guard.IsNotNull(installerFile, nameof(installerFile)); // Open package archive for reading using var stream = installerFile.OpenRead(); using var archive = new ZipArchive(stream); // Extract metadata from manifest List <ProcessorArchitecture> architectures = new(); if (isBundle) { var bundleManifestEntry = archive.GetEntry("AppxMetadata/AppxBundleManifest.xml"); using var bundleManifestStream = bundleManifestEntry.Open(); XPathDocument bundleManifest = new(bundleManifestStream); var archNodes = bundleManifest.CreateNavigator().Select("//Package/@Architecture"); do { var archNode = archNodes.Current; architectures.Add((ProcessorArchitecture)Enum.Parse(typeof(ProcessorArchitecture), archNode.Value, true)); } while (archNodes.MoveNext()); } else { var manifestEntry = archive.GetEntry("AppxManifest.xml"); using var manifestStream = manifestEntry.Open(); XPathDocument manifest = new(manifestStream); var archNode = manifest.CreateNavigator().SelectSingleNode("//Identity/@ProcessorArchitecture"); architectures.Add((ProcessorArchitecture)Enum.Parse(typeof(ProcessorArchitecture), archNode.Value, true)); } // Check Windows platform PlatWindows?currentPlat = PlatWindowsStringConverter.Parse(AnalyticsInfo.VersionInfo.DeviceFamily); if (!currentPlat.HasValue) { return("Cannot identify the current Windows platform."); } //else if (!AllowedPlatforms.Contains(currentPlat.Value)) //{ // return Title + " does not support " + currentPlat.ToString(); //} // Check CPU architecture var curArch = Package.Current.Id.Architecture; if (!architectures.Contains(curArch)) { return("Package does not support " + curArch.ToString()); } return(null); }
public override async Task <string> GetCannotBeInstalledReason() { // Check Windows platform PlatWindows?currentPlat = PlatWindowsStringConverter.Parse(AnalyticsInfo.VersionInfo.DeviceFamily); if (!currentPlat.HasValue) { return("Cannot identify the current Windows platform."); } else if (AllowedPlatforms != null && !AllowedPlatforms.Contains(currentPlat.Value)) { return(Title + " does not support " + currentPlat.ToString()); } // TODO: Check architecture, etc. return(null); }