public static void PrintAvailablePlan(this List <EditionTarget> targets)
 {
     foreach (var target in targets)
     {
         foreach (var str in ConversionPlanBuilder.PrintEditionTarget(target))
         {
             Logging.Log(str);
         }
     }
 }
Exemplo n.º 2
0
        public static void CreateISOMediaAdvanced(
            string ISOPath,
            string UUPPath,
            string LanguageCode,
            bool IntegrateUpdates,
            Common.CompressionType CompressionType,
            ProgressCallback progressCallback = null)
        {
            bool   result = true;
            string error  = "";

            List <EditionTarget> editionTargets;

            result = GetTargetedPlan(UUPPath, LanguageCode, out editionTargets, progressCallback);
            if (!result)
            {
                error = "An error occurred while getting target plans for the conversion.";
                goto error;
            }

            foreach (var ed in editionTargets)
            {
                foreach (var line in ConversionPlanBuilder.PrintEditionTarget(ed))
                {
                    progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, line);
                }
            }

            progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, "Enumerating files");

            var temp = Path.GetTempFileName();

            File.Delete(temp);
            Directory.CreateDirectory(temp);

            string WinREWIMFilePath   = Path.Combine(temp, "Winre.wim");
            string MediaRootPath      = Path.Combine(temp, "MediaRoot");
            string InstallWIMFilePath = CompressionType == Common.CompressionType.LZMS ?
                                        Path.Combine(MediaRootPath, "sources", "install.esd") :
                                        Path.Combine(MediaRootPath, "sources", "install.wim");

            //
            // Build installer
            //
            result = SetupMediaCreator.CreateSetupMedia(UUPPath, LanguageCode, MediaRootPath, WinREWIMFilePath, CompressionType, progressCallback);
            if (!result)
            {
                error = "An error occurred while creating setup media.";
                goto error;
            }

            //
            // Build Install.WIM/ESD
            //
            foreach (var ed in editionTargets)
            {
                result = HandleEditionPlan(ed, UUPPath, MediaRootPath, LanguageCode, InstallWIMFilePath, WinREWIMFilePath, CompressionType, progressCallback: progressCallback);
                if (!result)
                {
                    error = "An error occurred while handling edition plan for the following edition: " + ed.PlannedEdition.EditionName + " available as: " + ed.PlannedEdition.AvailabilityType;
                    goto error;
                }
            }

            BootlegEditionCreator.CleanupLanguagePackFolderIfRequired();

            //
            // Build ISO
            //
            result = UUPMediaCreator.CreateISO(MediaRootPath, ISOPath, progressCallback);
            if (!result)
            {
                error = "An error occurred while creating the ISO.";
                goto error;
            }

            progressCallback?.Invoke(Common.ProcessPhase.Done, true, 0, "");
            goto exit;

error:
            progressCallback?.Invoke(Common.ProcessPhase.Error, true, 0, error);

exit:
            return;
        }