propagate erroring exit codes

This commit is contained in:
Ellpeck 2020-09-01 00:49:06 +02:00
parent 90d7835791
commit 6642539c3a
3 changed files with 19 additions and 8 deletions

View file

@ -3,7 +3,7 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"nulastudio.ncbeauty": { "nulastudio.ncbeauty": {
"version": "1.2.8", "version": "1.2.9",
"commands": [ "commands": [
"ncbeauty" "ncbeauty"
] ]

View file

@ -13,7 +13,7 @@
<PackageIconUrl>https://raw.githubusercontent.com/Ellpeck/GameBundle/master/Logo.png</PackageIconUrl> <PackageIconUrl>https://raw.githubusercontent.com/Ellpeck/GameBundle/master/Logo.png</PackageIconUrl>
<PackAsTool>true</PackAsTool> <PackAsTool>true</PackAsTool>
<ToolCommandName>gamebundle</ToolCommandName> <ToolCommandName>gamebundle</ToolCommandName>
<VersionPrefix>1.2.1</VersionPrefix> <VersionPrefix>1.2.2</VersionPrefix>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -31,16 +31,22 @@ namespace GameBundle {
if (options.BuildWindows) { if (options.BuildWindows) {
Console.WriteLine("Bundling for windows"); 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) { if (options.BuildLinux) {
Console.WriteLine("Bundling for linux"); 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) { if (options.BuildMac) {
Console.WriteLine("Bundling for mac"); Console.WriteLine("Bundling for mac");
var dir = $"{bundleDir.FullName}/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) if (options.MacBundle)
CreateMacBundle(options, new DirectoryInfo(dir), proj.FullName); CreateMacBundle(options, new DirectoryInfo(dir), proj.FullName);
} }
@ -49,18 +55,23 @@ namespace GameBundle {
return 0; return 0;
} }
private static void Publish(Options options, FileInfo proj, string path, string rid) { private static int 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}"); 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 // Run beauty
var excludes = '"' + string.Join(";", options.ExcludedFiles) + '"'; var excludes = '"' + string.Join(";", options.ExcludedFiles) + '"';
var log = options.Verbose ? "Detail" : "Error"; 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 // Remove the beauty file since it's just a marker
var beautyFile = new FileInfo(Path.Combine(path, "NetCoreBeauty")); var beautyFile = new FileInfo(Path.Combine(path, "NetCoreBeauty"));
if (beautyFile.Exists) if (beautyFile.Exists)
beautyFile.Delete(); beautyFile.Delete();
return 0;
} }
private static int RunProcess(Options options, string program, string args, string workingDir = "") { private static int RunProcess(Options options, string program, string args, string workingDir = "") {