From 0c2670f55a5b2a464c544886d2c9cacfdf8eb4b0 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Mon, 1 Jan 2024 15:15:11 +0600 Subject: [PATCH] dotnet 8 --- diff-text/Program.cs | 9 +++--- diff-text/diff-text.csproj | 8 +++--- paradox-mod-merger/Diff.cs | 2 +- paradox-mod-merger/Merge.cs | 8 +++--- paradox-mod-merger/Program.cs | 30 ++++++++++---------- paradox-mod-merger/paradox-mod-merger.csproj | 7 +++-- publish_debug.sh | 2 +- publish_native.sh | 7 +++-- 8 files changed, 38 insertions(+), 35 deletions(-) diff --git a/diff-text/Program.cs b/diff-text/Program.cs index 7648448..c42df14 100644 --- a/diff-text/Program.cs +++ b/diff-text/Program.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Text; using DiffMatchPatch; -using DTLib.Ben.Demystifier; using DTLib.Console; using DTLib.Filesystem; @@ -26,17 +25,17 @@ public static class DiffText List? diff = null; bool noColors = false; new LaunchArgumentParser( - new LaunchArgument(new[] { "s", "string" }, + new LaunchArgument(["s", "string"], "shows difference of two strings", (s0, s1) => diff=TextDiff(s0, s1), "string0", "string1", 1), - new LaunchArgument(new[] { "f", "file" }, + new LaunchArgument(["f", "file"], "shows difference of two text files", (f0,f1) => diff=FileDiff(f0, f1), "file0", "file1", 1), - new LaunchArgument(new []{"p", "plain-text","no-colors"}, + new LaunchArgument(["p", "plain-text","no-colors"], "print diff in plain text format", ()=> noColors=true, 0) @@ -49,7 +48,7 @@ public static class DiffText { } catch (Exception ex) { - ColoredConsole.WriteLine("r", ex.ToStringDemystified()); + ColoredConsole.WriteLine("r", $"{ex.Message} at {ex.Source}"); return 1; } diff --git a/diff-text/diff-text.csproj b/diff-text/diff-text.csproj index a0f20aa..ad6dfb2 100644 --- a/diff-text/diff-text.csproj +++ b/diff-text/diff-text.csproj @@ -1,14 +1,14 @@ Exe - net7.0 - diff_text + net8.0 + 12 disable enable + diff_text - - + diff --git a/paradox-mod-merger/Diff.cs b/paradox-mod-merger/Diff.cs index 56fb961..c24e6d2 100644 --- a/paradox-mod-merger/Diff.cs +++ b/paradox-mod-merger/Diff.cs @@ -177,7 +177,7 @@ static class Diff var file = _file.RemoveBase(modp); if (all_files.TryGetValue(file.Str, out var associated_mods)) associated_mods.Add(modp.Str); - else all_files.Add(file.Str, new List(1) { modp.Str }); + else all_files.Add(file.Str, [modp.Str]); } } diff --git a/paradox-mod-merger/Merge.cs b/paradox-mod-merger/Merge.cs index 1a5e473..42455c8 100644 --- a/paradox-mod-merger/Merge.cs +++ b/paradox-mod-merger/Merge.cs @@ -50,7 +50,7 @@ static class Merge public static void MergeInto(IOPath moddir, IOPath outDir) { - HandleConflicts(new[] { moddir, outDir }); + HandleConflicts([moddir, outDir]); IOPath out_modlist_file = Path.Concat(outDir, modlist_filename); File.AppendAllText(out_modlist_file, $"{moddir.LastName()}\n"); ModDirCopy(moddir, outDir, out_modlist_file); @@ -102,9 +102,9 @@ static class Merge public static void UpdateMods(IOPath updated_mods_dir, IOPath[] outdated_dirs, IOPath backup_dir) { var src_dir_mods = Directory.GetDirectories(updated_mods_dir).ToList(); - List not_found_mods = new List(); - List changed_mods = new List(); - List unchanged_mods = new List(); + List not_found_mods = []; + List changed_mods = []; + List unchanged_mods = []; foreach (IOPath outdated_mods_dir in outdated_dirs) foreach (var mod in Directory.GetDirectories(outdated_mods_dir)) diff --git a/paradox-mod-merger/Program.cs b/paradox-mod-merger/Program.cs index 9576615..e46256a 100644 --- a/paradox-mod-merger/Program.cs +++ b/paradox-mod-merger/Program.cs @@ -30,7 +30,7 @@ public static class Program _logger.LogInfo(b.ToString()); } - public static bool YesAll = false; + public static bool YesAll; static int Main(string[] args) { @@ -42,67 +42,67 @@ public static class Program string outPath = "" ; new LaunchArgumentParser( - new LaunchArgument(new[] { "o", "out" }, + new LaunchArgument(["o", "out"], "Sets output path", p => outPath = p, "out_path", 0), - new LaunchArgument(new[] { "y", "yes-all" }, + new LaunchArgument(["y", "yes-all"], "Automatically answers [Y] to all questions", () => YesAll = true, 0), - new LaunchArgument(new[] { "clear" }, + new LaunchArgument(["clear"], "Clear mod files and put them into separate dirs in output dir. Requires -o", wdir => Workshop.ClearWorkshop(wdir, outPath), "workshop_dir", 1), - new LaunchArgument(new[] { "diff" }, + new LaunchArgument(["diff"], "Compares mod files by hash", p => Diff.DiffCommandHandler(p), "first_mod_directory:second_mod_directory:...", 1), - new LaunchArgument(new[] { "diff-detailed" }, + new LaunchArgument(["diff-detailed"], "reads conflicts_XXX.dtsod file and shows text diff for each file", p => Diff.DiffDetailedCommandHandler(p), "conflicts_dtsod_path", 1), - new LaunchArgument(new[] { "merge-subdirs" }, + new LaunchArgument(["merge-subdirs"], "Merges mods and shows conflicts. Requires -o", d => Merge.MergeAll(Directory.GetDirectories(d), outPath), "dir_with_mods", 1), - new LaunchArgument(new[] { "merge-into", "merge-single" }, + new LaunchArgument(["merge-into", "merge-single"], "Merges one mod into output dir and shows conflicts. Requires -o", mod => Merge.MergeInto(mod, outPath), "mod_dir", 1), - new LaunchArgument(new[] { "gen-rus-locale" }, + new LaunchArgument(["gen-rus-locale"], "Creates l_russian copy of english locale in output directory. Requires -o", eng => Localisation.GenerateRussian(eng, outPath), "english_locale_path", 1), - new LaunchArgument(new[] { "desc" }, + new LaunchArgument(["desc"], "Downloads mod description from steam to new file in outDir. Requires -o", id => Workshop.CreateDescFile(id, outPath).GetAwaiter().GetResult(), "mod_id", 1), - new LaunchArgument(new[] { "rename" }, + new LaunchArgument(["rename"], "Renames mods in directory", (modsdir, replace_pairs) => Merge.RenameModsCommandHandler(modsdir, replace_pairs), "dir_with_mods", "replace_pairs (old_name:new_name:...)", 1), - new LaunchArgument(new[] { "update-mods" }, + new LaunchArgument(["update-mods"], "Updates mods in [outdated_dir0...outdated_dirN] to new versions if found in updated_mods_dir. " + "Moves old mods to backup_dir defined by -o.", (updated, outdated) => Merge.UpdateMods(updated, SplitArgToPaths(outdated, true), outPath), "updated_mods_dir", "outdated_dir OR outdated_dir0:...:outdated_dirN", 1), - new LaunchArgument(new[] { "clean-locales" }, + new LaunchArgument(["clean-locales"], "Deletes all localisations except l_russian and l_english.", locdir => Localisation.Clean(locdir), "localisation_dir", 1), - new LaunchArgument(new[] { "gen-collection-json" }, + new LaunchArgument(["gen-collection-json"], "Generates json file representing mod collection in format readable by pdx launcher and IronyModManager." + "Requires -o", (connected_dirs) => IronyIntegration.GenerateIronyCollection(connected_dirs, outPath), @@ -130,7 +130,7 @@ public static class Program else if (connected_parts.Contains(';')) part_sep = ';'; else if (allow_one_part) - return new []{connected_parts}; + return [connected_parts]; else throw new Exception($"<{connected_parts}> doesn't contain any separators (:/;)"); return connected_parts.Split(part_sep); diff --git a/paradox-mod-merger/paradox-mod-merger.csproj b/paradox-mod-merger/paradox-mod-merger.csproj index 00fc4c7..28fbb18 100644 --- a/paradox-mod-merger/paradox-mod-merger.csproj +++ b/paradox-mod-merger/paradox-mod-merger.csproj @@ -2,11 +2,12 @@ Exe - net7.0 + net8.0 + 12 + disable + enable ParadoxModMerger paradox-mod-merger - latest - enable diff --git a/publish_debug.sh b/publish_debug.sh index 8ddd9c7..81bea59 100644 --- a/publish_debug.sh +++ b/publish_debug.sh @@ -1,4 +1,4 @@ #!/bin/sh rm -rf publish mkdir publish -dotnet publish -c debug -o publish -f net7.0 +dotnet publish -c debug -o publish diff --git a/publish_native.sh b/publish_native.sh index ed9378a..fc0dab0 100644 --- a/publish_native.sh +++ b/publish_native.sh @@ -6,13 +6,16 @@ function publish_aot() { echo "---------[$1]---------" cd "$1" rm -rf bin/publish - dotnet publish -c Release -o bin/publish -p:PublishAot=true + dotnet publish -c Release -o bin/publish -p:PublishAot=true --self-contained + sleep 0.1 + rm bin/publish/*.pdb mkdir -p ../publish cp -r bin/publish/* ../publish/ cd .. } rm -rf publish +# paradox-mod-merger publishes diff-text as dotnet executable +#publish_aot diff-text publish_aot paradox-mod-merger -publish_aot diff-text ls -lh publish