From 8386ed5cb1c3b004b1153524f322a0aff590b343 Mon Sep 17 00:00:00 2001 From: BlueRain-debug <68976789+BlueRain-debug@users.noreply.github.com> Date: Fri, 20 Feb 2026 02:08:13 +0800 Subject: [PATCH] Update LocateFilesForSetupMediaCreation to include edition parameter for Base Edition matching Added an edition parameter to ensure the process uses a matching Base Edition when creating setup media. This should improve accuracy during the media creation process. --- .../FileLocator.cs | 32 ++++++++++++++++++- .../Installer/SetupMediaCreator.cs | 5 +-- .../MediaCreator.cs | 2 +- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/UnifiedUpdatePlatform.Media.Creator/FileLocator.cs b/src/UnifiedUpdatePlatform.Media.Creator/FileLocator.cs index 2c5540d3..6f30ece1 100644 --- a/src/UnifiedUpdatePlatform.Media.Creator/FileLocator.cs +++ b/src/UnifiedUpdatePlatform.Media.Creator/FileLocator.cs @@ -96,10 +96,40 @@ internal static (bool Succeeded, string BaseESD) LocateFilesForSetupMediaCreatio string UUPPath, string LanguageCode, IEnumerable CompositionDatabases, - ProgressCallback? progressCallback = null) + ProgressCallback? progressCallback = null, + string edition = null) { progressCallback?.Invoke(Common.Messaging.Common.ProcessPhase.ReadingMetadata, true, 0, "Looking up Composition Database in order to find a Base ESD image appropriate for building windows setup files."); + if (edition != null) + { + CompDB? compDB = GetEditionCompDBForLanguage(CompositionDatabases, edition, LanguageCode); + + if (compDB != null) + { + foreach (Package feature in compDB.Features.Feature[0].Packages.Package) + { + Package pkg = compDB.Packages.Package.First(x => x.ID == feature.ID); + + string file = pkg.GetCommonlyUsedIncorrectFileName(); + + if (feature.PackageType == "MetadataESD") + { + if (!File.Exists(Path.Combine(UUPPath, file))) + { + file = pkg.Payload.PayloadItem[0].Path.Replace('\\', Path.DirectorySeparatorChar); + if (!File.Exists(Path.Combine(UUPPath, file))) + { + break; + } + } + + return (true, Path.Combine(UUPPath, file)); + } + } + } + } + HashSet filteredCompositionDatabases = CompositionDatabases.GetEditionCompDBsForLanguage(LanguageCode); if (filteredCompositionDatabases.Count > 0) { diff --git a/src/UnifiedUpdatePlatform.Media.Creator/Installer/SetupMediaCreator.cs b/src/UnifiedUpdatePlatform.Media.Creator/Installer/SetupMediaCreator.cs index a2284966..1e096263 100644 --- a/src/UnifiedUpdatePlatform.Media.Creator/Installer/SetupMediaCreator.cs +++ b/src/UnifiedUpdatePlatform.Media.Creator/Installer/SetupMediaCreator.cs @@ -37,12 +37,13 @@ public static bool CreateSetupMedia( Common.Messaging.Common.CompressionType CompressionType, IEnumerable CompositionDatabases, TempManager tempManager, - ProgressCallback progressCallback = null) + ProgressCallback progressCallback = null, + string edition = null) { bool result = true; string BaseESD = null; - (result, BaseESD) = FileLocator.LocateFilesForSetupMediaCreation(UUPPath, LanguageCode, CompositionDatabases, progressCallback); + (result, BaseESD) = FileLocator.LocateFilesForSetupMediaCreation(UUPPath, LanguageCode, CompositionDatabases, progressCallback, edition: edition); if (!result) { goto exit; diff --git a/src/UnifiedUpdatePlatform.Media.Creator/MediaCreator.cs b/src/UnifiedUpdatePlatform.Media.Creator/MediaCreator.cs index 566b366e..19c2678c 100644 --- a/src/UnifiedUpdatePlatform.Media.Creator/MediaCreator.cs +++ b/src/UnifiedUpdatePlatform.Media.Creator/MediaCreator.cs @@ -419,7 +419,7 @@ public static void CreateISOMedia( // // Build installer // - result = SetupMediaCreator.CreateSetupMedia(UUPPath, LanguageCode, MediaRootPath, WinREWIMFilePath, CompressionType, CompositionDatabases, tempManager, progressCallback); + result = SetupMediaCreator.CreateSetupMedia(UUPPath, LanguageCode, MediaRootPath, WinREWIMFilePath, CompressionType, CompositionDatabases, tempManager, progressCallback: progressCallback, edition: Edition); if (!result) { error = "An error occurred while creating setup media.";