Skip to content

Commit

Permalink
Allow specifying the build configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdoomen committed Oct 18, 2023
1 parent b43127c commit 89cfe62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
"build": {
"type": "object",
"properties": {
"Configuration": {
"type": "string",
"description": "The solution configuration to build. Default is 'Debug' (local) or 'CI' (server)",
"enum": [
"CI",
"Debug"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
Expand Down
9 changes: 6 additions & 3 deletions Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class Build : NukeBuild

string PullRequestBase => GitHubActions?.BaseRef;

[Parameter("The solution configuration to build. Default is 'Debug' (local) or 'CI' (server).")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.CI;

[Parameter("Use this parameter if you encounter build problems in any way, " +
"to generate a .binlog file which holds some useful information.")]
readonly bool? GenerateBinLog;
Expand Down Expand Up @@ -126,7 +129,7 @@ class Build : NukeBuild
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetConfiguration(Configuration.CI)
.SetConfiguration(Configuration)
.When(GenerateBinLog is true, _ => _
.SetBinaryLog(ArtifactsDirectory / $"{Solution.Core.FluentAssertions.Name}.binlog")
)
Expand All @@ -145,7 +148,7 @@ class Build : NukeBuild
Project project = Solution.Specs.Approval_Tests;
DotNetTest(s => s
.SetConfiguration(Configuration.Release)
.SetConfiguration(Configuration == Configuration.Debug ? "Debug" : "Release")
.SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US")
.EnableNoBuild()
.SetResultsDirectory(TestResultsDirectory)
Expand Down Expand Up @@ -318,7 +321,7 @@ from framework in supportedFrameworks
DotNetPack(s => s
.SetProject(Solution.Core.FluentAssertions)
.SetOutputDirectory(ArtifactsDirectory)
.SetConfiguration(Configuration.Release)
.SetConfiguration(Configuration == Configuration.Debug ? "Debug" : "Release")
.EnableNoLogo()
.EnableNoRestore()
.EnableContinuousIntegrationBuild() // Necessary for deterministic builds
Expand Down
6 changes: 2 additions & 4 deletions Build/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
[TypeConverter(typeof(TypeConverter<Configuration>))]
public class Configuration : Enumeration
{
public static Configuration Debug { get; } = new() { Value = nameof(Debug) };
public static Configuration Debug = new() { Value = nameof(Debug) };

public static Configuration Release { get; } = new() { Value = nameof(Release) };

public static Configuration CI { get; } = new() { Value = nameof(CI) };
public static Configuration CI = new() { Value = nameof(CI) };

public static implicit operator string(Configuration configuration)
{
Expand Down

0 comments on commit 89cfe62

Please sign in to comment.