static void ApplyRules(ModData modData, IReadWritePackage mapPackage, IEnumerable <UpdateRule> rules) { var externalFilenames = new HashSet <string>(); foreach (var rule in rules) { Console.WriteLine("{0}: {1}", rule.GetType().Name, rule.Name); var mapFiles = new YamlFileSet(); var manualSteps = new List <string>(); Console.Write(" Updating map... "); try { manualSteps = UpdateUtils.UpdateMap(modData, mapPackage, rule, out mapFiles, externalFilenames); } catch (Exception ex) { Console.WriteLine("FAILED"); Console.WriteLine(); Console.WriteLine(" The automated changes for this rule were not applied because of an error."); Console.WriteLine(" After the issue reported below is resolved you should run the updater"); Console.WriteLine(" with SOURCE set to {0} to retry these changes", rule.GetType().Name); Console.WriteLine(); Console.WriteLine(" The exception reported was:"); Console.WriteLine(" " + ex.ToString().Replace("\n", "\n ")); continue; } // Files are saved after each successful automated rule update mapFiles.Save(); Console.WriteLine("COMPLETE"); if (manualSteps.Any()) { Console.WriteLine(" Manual changes are required to complete this update:"); foreach (var manualStep in manualSteps) { Console.WriteLine(" * " + manualStep.Replace("\n", "\n ")); } } Console.WriteLine(); } if (externalFilenames.Any()) { Console.WriteLine("The following shared yaml files referenced by the map have been ignored:"); Console.WriteLine(UpdateUtils.FormatMessageList(externalFilenames)); Console.WriteLine("These files are assumed to have already been updated by the --update-mod command"); Console.WriteLine(); } Console.WriteLine("Semi-automated update complete."); Console.WriteLine("Please review the messages above for any manual actions that must be applied."); }
static void ApplyRules(ModData modData, IEnumerable <UpdateRule> rules, bool skipMaps) { Console.WriteLine(); var logWriter = File.CreateText("update.log"); logWriter.AutoFlush = true; var externalFilenames = new HashSet <string>(); foreach (var rule in rules) { var manualSteps = new List <string>(); var allFiles = new YamlFileSet(); LogLine(logWriter, "{0}: {1}", rule.GetType().Name, rule.Name); try { Log(logWriter, " Updating mod... "); manualSteps.AddRange(UpdateUtils.UpdateMod(modData, rule, out allFiles, externalFilenames)); LogLine(logWriter, "COMPLETE"); } catch (Exception ex) { Console.WriteLine("FAILED"); LogLine(logWriter); LogLine(logWriter, " The automated changes for this rule were not applied because of an error."); LogLine(logWriter, " After the issue reported below is resolved you should run the updater"); LogLine(logWriter, " with SOURCE set to {0} to retry these changes", rule.GetType().Name); LogLine(logWriter); LogLine(logWriter, " The exception reported was:"); LogLine(logWriter, " " + ex.ToString().Replace("\n", "\n ")); continue; } Log(logWriter, " Updating system maps... "); if (!skipMaps) { var mapsFailed = false; var mapExternalFilenames = new HashSet <string>(); foreach (var package in modData.MapCache.EnumerateMapPackagesWithoutCaching()) { try { var mapSteps = UpdateUtils.UpdateMap(modData, package, rule, out var mapFiles, mapExternalFilenames); allFiles.AddRange(mapFiles); if (mapSteps.Any()) { manualSteps.Add("Map: " + package.Name + ":\n" + UpdateUtils.FormatMessageList(mapSteps)); } } catch (Exception ex) { LogLine(logWriter, "FAILED"); LogLine(logWriter); LogLine(logWriter, " The automated changes for this rule were not applied because of an error."); LogLine(logWriter, " After the issue reported below is resolved you should run the updater"); LogLine(logWriter, " with SOURCE set to {0} to retry these changes", rule.GetType().Name); LogLine(logWriter); LogLine(logWriter, " The map that caused the error was:"); LogLine(logWriter, " " + package.Name); LogLine(logWriter); LogLine(logWriter, " The exception reported was:"); LogLine(logWriter, " " + ex.ToString().Replace("\n", "\n ")); mapsFailed = true; break; } } if (mapsFailed) { continue; } LogLine(logWriter, "COMPLETE"); } else { LogLine(logWriter, "SKIPPED"); } // Files are saved after each successful automated rule update allFiles.Save(); if (manualSteps.Any()) { LogLine(logWriter, " Manual changes are required to complete this update:"); LogLine(logWriter, UpdateUtils.FormatMessageList(manualSteps, 1)); } LogLine(logWriter); } if (externalFilenames.Any()) { LogLine(logWriter, "The following external mod files have been ignored:"); LogLine(logWriter, UpdateUtils.FormatMessageList(externalFilenames)); LogLine(logWriter, "These files should be updated by running --update-mod on the referenced mod(s)"); LogLine(logWriter); } Console.WriteLine("Semi-automated update complete."); Console.WriteLine("Please review the messages above for any manual actions that must be applied."); Console.WriteLine("These messages have also been written to an update.log file in the current directory."); }