Skip to content

Commit

Permalink
Fix nuke build
Browse files Browse the repository at this point in the history
  • Loading branch information
ImoutoChan committed Nov 23, 2024
1 parent 9c2fadf commit 1a0775b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 33 deletions.
52 changes: 29 additions & 23 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
]
}
41 changes: 31 additions & 10 deletions Tools/NukeBuild/Z7Tasks.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Nuke.Common.IO;
using Nuke.Common.Tooling;

Expand All @@ -9,20 +9,26 @@ public static void PackAs7z(Action<Z7SfxSettings> 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<ToolSettings, IProcess> ProcessExitHandler => (_, process) =>
public Action<OutputType, string> 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
{
Expand Down Expand Up @@ -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);
Expand All @@ -75,5 +81,20 @@ protected override Arguments ConfigureProcessArguments(Arguments arguments)
.Add("\"{0}\"", ArchiveName)
.Add("\"{0}\\", SourceName);
}

public string GetArguments()
{
var arguments = new List<string>();

arguments.Add(Command);

if (!string.IsNullOrWhiteSpace(Switch))
arguments.Add(Switch);

arguments.Add($"\"{ArchiveName}\"");
arguments.Add($"\"{SourceName}\\");

return string.Join(" ", arguments);
}
}
}

0 comments on commit 1a0775b

Please sign in to comment.