diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 5da34361..6cdd5b6d 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,27 +1,5 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "properties": { - "Configuration": { - "type": "string", - "description": "Configuration to build - Default is 'Release'", - "enum": [ - "Debug", - "Release" - ] - }, - "Solution": { - "type": "string", - "description": "Path to a solution file that is automatically loaded" - }, - "VersionedFolder": { - "type": "string", - "description": "Insert version into the artefacts - Default is 'True'", - "enum": [ - "False", - "True" - ] - } - }, "definitions": { "Host": { "type": "string", @@ -123,5 +101,33 @@ } } }, - "$ref": "#/definitions/NukeBuild" + "allOf": [ + { + "properties": { + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Release'", + "enum": [ + "Debug", + "Release" + ] + }, + "Solution": { + "type": "string", + "description": "Path to a solution file that is automatically loaded" + }, + "VersionedFolder": { + "type": "string", + "description": "Insert version into the artefacts - Default is 'True'", + "enum": [ + "False", + "True" + ] + } + } + }, + { + "$ref": "#/definitions/NukeBuild" + } + ] } diff --git a/Tools/NukeBuild/Z7Tasks.cs b/Tools/NukeBuild/Z7Tasks.cs index af5b5868..c1f20922 100644 --- a/Tools/NukeBuild/Z7Tasks.cs +++ b/Tools/NukeBuild/Z7Tasks.cs @@ -1,5 +1,5 @@ using System; -using System.Linq; +using System.Collections.Generic; using Nuke.Common.IO; using Nuke.Common.Tooling; @@ -9,20 +9,26 @@ public static void PackAs7z(Action configurator) { var settings = new Z7SfxSettings(); configurator(settings); - - ProcessTasks.StartProcess(settings).WaitForExit(); + + ProcessTasks + .StartProcess( + settings.ProcessToolPath, + settings.GetArguments(), + logger: settings.ProcessExitHandler, + logOutput: true, + logInvocation: true) + .WaitForExit(); } - public class Z7SfxSettings : ToolSettings + public class Z7SfxSettings { - public override string ProcessToolPath => @"C:\Program Files\7-Zip\7z.exe"; + public string ProcessToolPath => @"C:\Program Files\7-Zip\7z.exe"; - public override Action ProcessExitHandler => (_, process) => + public Action ProcessExitHandler => (type, text) => { - if (process.Output.Any(x => x.Type == OutputType.Err)) + if (type == OutputType.Err) { - Serilog.Log.Error( - string.Join("\n", process.Output.Where(x => x.Type == OutputType.Err).Select(x => x.Text))); + Serilog.Log.Error(string.Join("\n", text)); } else { @@ -62,7 +68,7 @@ public Z7SfxSettings SetSourceDirectory(string sourceName) return this; } - protected override Arguments ConfigureProcessArguments(Arguments arguments) + protected Arguments ConfigureProcessArguments(Arguments arguments) { var resultArguments = arguments .Add(Command); @@ -75,5 +81,20 @@ protected override Arguments ConfigureProcessArguments(Arguments arguments) .Add("\"{0}\"", ArchiveName) .Add("\"{0}\\", SourceName); } + + public string GetArguments() + { + var arguments = new List(); + + arguments.Add(Command); + + if (!string.IsNullOrWhiteSpace(Switch)) + arguments.Add(Switch); + + arguments.Add($"\"{ArchiveName}\""); + arguments.Add($"\"{SourceName}\\"); + + return string.Join(" ", arguments); + } } }