From 6642539c3abd5a9eee4db31605563d2fd77a2d2a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 1 Sep 2020 00:49:06 +0200 Subject: [PATCH] propagate erroring exit codes --- GameBundle/.config/dotnet-tools.json | 2 +- GameBundle/GameBundle.csproj | 2 +- GameBundle/Program.cs | 23 +++++++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/GameBundle/.config/dotnet-tools.json b/GameBundle/.config/dotnet-tools.json index 54c2e1d..8229967 100644 --- a/GameBundle/.config/dotnet-tools.json +++ b/GameBundle/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "nulastudio.ncbeauty": { - "version": "1.2.8", + "version": "1.2.9", "commands": [ "ncbeauty" ] diff --git a/GameBundle/GameBundle.csproj b/GameBundle/GameBundle.csproj index efb5151..18f6d8c 100644 --- a/GameBundle/GameBundle.csproj +++ b/GameBundle/GameBundle.csproj @@ -13,7 +13,7 @@ https://raw.githubusercontent.com/Ellpeck/GameBundle/master/Logo.png true gamebundle - 1.2.1 + 1.2.2 diff --git a/GameBundle/Program.cs b/GameBundle/Program.cs index 158edec..f4c649d 100644 --- a/GameBundle/Program.cs +++ b/GameBundle/Program.cs @@ -31,16 +31,22 @@ namespace GameBundle { if (options.BuildWindows) { Console.WriteLine("Bundling for windows"); - Publish(options, proj, $"{bundleDir.FullName}/win", options.Publish32Bit ? "win-x86" : "win-x64"); + var res = Publish(options, proj, $"{bundleDir.FullName}/win", options.Publish32Bit ? "win-x86" : "win-x64"); + if (res != 0) + return res; } if (options.BuildLinux) { Console.WriteLine("Bundling for linux"); - Publish(options, proj, $"{bundleDir.FullName}/linux", "linux-x64"); + var res = Publish(options, proj, $"{bundleDir.FullName}/linux", "linux-x64"); + if (res != 0) + return res; } if (options.BuildMac) { Console.WriteLine("Bundling for mac"); var dir = $"{bundleDir.FullName}/mac"; - Publish(options, proj, dir, "osx-x64"); + var res = Publish(options, proj, dir, "osx-x64"); + if (res != 0) + return res; if (options.MacBundle) CreateMacBundle(options, new DirectoryInfo(dir), proj.FullName); } @@ -49,18 +55,23 @@ namespace GameBundle { return 0; } - private static void Publish(Options options, FileInfo proj, string path, string rid) { - RunProcess(options, "dotnet", $"publish {proj.FullName} -o {path} -r {rid} -c {options.BuildConfig} /p:PublishTrimmed={options.Trim}"); + private static int Publish(Options options, FileInfo proj, string path, string rid) { + var publishResult = RunProcess(options, "dotnet", $"publish {proj.FullName} -o {path} -r {rid} -c {options.BuildConfig} /p:PublishTrimmed={options.Trim}"); + if (publishResult != 0) + return publishResult; // Run beauty var excludes = '"' + string.Join(";", options.ExcludedFiles) + '"'; var log = options.Verbose ? "Detail" : "Error"; - RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True {path} {options.LibFolder} {excludes}", AppDomain.CurrentDomain.BaseDirectory); + var beautyResult = RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True {path} {options.LibFolder} {excludes}", AppDomain.CurrentDomain.BaseDirectory); + if (beautyResult != 0) + return beautyResult; // Remove the beauty file since it's just a marker var beautyFile = new FileInfo(Path.Combine(path, "NetCoreBeauty")); if (beautyFile.Exists) beautyFile.Delete(); + return 0; } private static int RunProcess(Options options, string program, string args, string workingDir = "") {