From 02b6fa5194a62811e43fccbee1f249fbbf3efdc1 Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Tue, 8 Sep 2026 09:06:56 +1000 Subject: [PATCH 1/2] Switch OctoVersion.Tool package reference to Octopus.OctoVersion.Tool OctoVersion.Tool was renamed to Octopus.OctoVersion.Tool; the old package id no longer has the pinned 0.2.963 version available, breaking restore. Bumped to the latest available release. Co-Authored-By: Claude Sonnet 5 --- build/_build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/_build.csproj b/build/_build.csproj index 595b71e..30191a5 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -12,7 +12,7 @@ - + From f8f17084f2c9444473a3f8c31df8e768e0968648 Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Tue, 8 Sep 2026 15:43:51 +1000 Subject: [PATCH 2/2] Upgrade Nuke.Common to 10.1.0 so the build runs on .NET 10 Nuke.Common 6.0.1 clones its tool settings with BinaryFormatter, which .NET 9 removed from the runtime, so every DotNet* task threw PlatformNotSupportedException once the build project moved to net10.0. 6.0.1 also only knows the pre-rename OctoVersion.Tool package id. Ports Build.cs to the Nuke 10 APIs, matching the shape used in Ocl. Co-Authored-By: Claude Opus 5 --- .gitignore | 3 + .nuke/build.schema.json | 141 +++++++++++++++++++++------------------- build/Build.cs | 72 ++++++++++---------- build/_build.csproj | 7 +- 4 files changed, 115 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index ae07e6b..2776506 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,6 @@ TestResult.xml # macOS Finder metadata .DS_Store + +# Test output +TestResults/ diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 4ac368a..66c3fd9 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,23 +1,49 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Build Schema", - "$ref": "#/definitions/build", "definitions": { - "build": { - "type": "object", + "Host": { + "type": "string", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "ExecutableTarget": { + "type": "string", + "enum": [ + "Clean", + "Compile", + "CopyToLocalPackages", + "Pack", + "Restore", + "Test" + ] + }, + "Verbosity": { + "type": "string", + "description": "", + "enum": [ + "Verbose", + "Normal", + "Minimal", + "Quiet" + ] + }, + "NukeBuild": { "properties": { - "AutoDetectBranch": { - "type": "boolean", - "description": "Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI" - }, - "Configuration": { - "type": "string", - "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", - "enum": [ - "Debug", - "Release" - ] - }, "Continue": { "type": "boolean", "description": "Indicates to continue a previously failed build attempt" @@ -27,33 +53,13 @@ "description": "Shows the help text for this build assembly" }, "Host": { - "type": "string", "description": "Host for execution. Default is 'automatic'", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" - ] + "$ref": "#/definitions/Host" }, "NoLogo": { "type": "boolean", "description": "Disables displaying the NUKE logo" }, - "OCTOVERSION_CurrentBranch": { - "type": "string", - "description": "Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable OCTOVERSION_CurrentBranch" - }, "Partition": { "type": "string", "description": "Partition to use on CI" @@ -77,47 +83,50 @@ "type": "array", "description": "List of targets to be skipped. Empty list skips all dependencies", "items": { - "type": "string", - "enum": [ - "Clean", - "Compile", - "CopyToLocalPackages", - "Pack", - "Restore", - "Test" - ] + "$ref": "#/definitions/ExecutableTarget" } }, - "Solution": { - "type": "string", - "description": "Path to a solution file that is automatically loaded" - }, "Target": { "type": "array", "description": "List of targets to be invoked. Default is '{default_target}'", "items": { - "type": "string", - "enum": [ - "Clean", - "Compile", - "CopyToLocalPackages", - "Pack", - "Restore", - "Test" - ] + "$ref": "#/definitions/ExecutableTarget" } }, "Verbosity": { - "type": "string", "description": "Logging verbosity during build execution. Default is 'Normal'", + "$ref": "#/definitions/Verbosity" + } + } + } + }, + "allOf": [ + { + "properties": { + "AutoDetectBranch": { + "type": "boolean", + "description": "Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI" + }, + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", "enum": [ - "Minimal", - "Normal", - "Quiet", - "Verbose" + "Debug", + "Release" ] + }, + "OCTOVERSION_CurrentBranch": { + "type": "string", + "description": "Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable OCTOVERSION_CurrentBranch" + }, + "Solution": { + "type": "string", + "description": "Path to a solution file that is automatically loaded" } } + }, + { + "$ref": "#/definitions/NukeBuild" } - } -} \ No newline at end of file + ] +} diff --git a/build/Build.cs b/build/Build.cs index 0590e59..8b16aa3 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,70 +1,66 @@ -// ReSharper disable RedundantUsingDirective - -using System; -using System.Linq; using Nuke.Common; -using Nuke.Common.CI; using Nuke.Common.CI.TeamCity; using Nuke.Common.Execution; -using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; -using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.OctoVersion; using Nuke.Common.Utilities.Collections; -using static Nuke.Common.EnvironmentInfo; -using static Nuke.Common.IO.FileSystemTasks; -using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.Tools.DotNet.DotNetTasks; -[CheckBuildProjectConfigurations] -[ShutdownDotNetAfterServerBuild] +[UnsetVisualStudioEnvironmentVariables] class Build : NukeBuild { [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] - public Configuration Configuration => IsLocalBuild ? Configuration.Debug : Configuration.Release; + readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; + + [Solution] readonly Solution Solution; - [Parameter("Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable OCTOVERSION_CurrentBranch.", Name = "OCTOVERSION_CurrentBranch")] + [Parameter("Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable OCTOVERSION_CurrentBranch.", + Name = "OCTOVERSION_CurrentBranch")] readonly string BranchName; + [Parameter("Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI.")] readonly bool AutoDetectBranch = IsLocalBuild; - [OctoVersion(UpdateBuildNumber = true, BranchParameter = nameof(BranchName), AutoDetectBranchParameter = nameof(AutoDetectBranch), Framework = "net8.0")] - readonly OctoVersionInfo OctoVersionInfo; - [Solution] readonly Solution Solution; + [OctoVersion(UpdateBuildNumber = true, BranchMember = nameof(BranchName), + AutoDetectBranchMember = nameof(AutoDetectBranch), Framework = "net10.0")] + readonly OctoVersionInfo OctoVersionInfo; AbsolutePath SourceDirectory => RootDirectory / "source"; - AbsolutePath TestsDirectory => RootDirectory / "tests"; AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; - AbsolutePath PublishDirectory => RootDirectory / "publish"; AbsolutePath LocalPackagesDirectory => RootDirectory / ".." / "LocalPackages"; Target Clean => _ => _ + .Before(Restore) .Executes(() => { - SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); - TestsDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults").ForEach(DeleteDirectory); - EnsureCleanDirectory(ArtifactsDirectory); - EnsureCleanDirectory(PublishDirectory); + SourceDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults").ForEach(d => d.DeleteDirectory()); + ArtifactsDirectory.CreateOrCleanDirectory(); }); + Target Restore => _ => _ - .DependsOn(Clean) .Executes(() => { - DotNetRestore(s => s + DotNetRestore(_ => _ .SetProjectFile(Solution)); }); + Target Compile => _ => _ + .DependsOn(Clean) .DependsOn(Restore) .Executes(() => { - DotNetBuild(s => s + Serilog.Log.Information("Building Octopus.CoreParsers.Hcl v{Version}", OctoVersionInfo.FullSemVer); + + DotNetBuild(_ => _ .SetProjectFile(Solution) .SetConfiguration(Configuration) .SetVersion(OctoVersionInfo.FullSemVer) + .SetInformationalVersion(OctoVersionInfo.InformationalVersion) .EnableNoRestore()); }); + Target Test => _ => _ .DependsOn(Compile) .Executes(() => @@ -73,11 +69,13 @@ class Build : NukeBuild .SetProjectFile(Solution) .SetConfiguration(Configuration) .SetLoggers("trx") - .SetVerbosity(DotNetVerbosity.Normal) + .SetVerbosity(DotNetVerbosity.normal) .EnableNoBuild() .EnableNoRestore()); - GlobFiles(SourceDirectory, "**/*.trx") - .ForEach(x => CopyFileToDirectory(x, ArtifactsDirectory, FileExistsPolicy.Overwrite)); + + // TeamCity reads test results from the published artifacts. + SourceDirectory.GlobFiles("**/*.trx") + .ForEach(f => f.CopyToDirectory(ArtifactsDirectory, ExistsPolicy.FileOverwrite)); }); Target Pack => _ => _ @@ -90,22 +88,20 @@ class Build : NukeBuild .SetConfiguration(Configuration) .SetOutputDirectory(ArtifactsDirectory) .EnableNoBuild() - .AddProperty("Version", OctoVersionInfo.FullSemVer) - ); + .AddProperty("Version", OctoVersionInfo.FullSemVer)); TeamCity.Instance?.PublishArtifacts(ArtifactsDirectory / $"Octopus.CoreParsers.Hcl.{OctoVersionInfo.FullSemVer}.nupkg"); }); Target CopyToLocalPackages => _ => _ .OnlyWhenStatic(() => IsLocalBuild) - .DependsOn(Pack) + .TriggeredBy(Pack) .Executes(() => { - GlobFiles(ArtifactsDirectory, $"*.{OctoVersionInfo.FullSemVer}.nupkg") - .ForEach(x => CopyFileToDirectory(x, LocalPackagesDirectory, FileExistsPolicy.Overwrite)); + LocalPackagesDirectory.CreateDirectory(); + (ArtifactsDirectory / $"Octopus.CoreParsers.Hcl.{OctoVersionInfo.FullSemVer}.nupkg") + .CopyToDirectory(LocalPackagesDirectory, ExistsPolicy.FileOverwrite); }); - public static int Main() => Execute( - x => x.Pack, - x => x.CopyToLocalPackages); -} \ No newline at end of file + public static int Main() => Execute(x => x.Pack); +} diff --git a/build/_build.csproj b/build/_build.csproj index 30191a5..393e0d2 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -4,7 +4,7 @@ Exe net10.0 - CS0649;CS0169 + CS0649;CS0169;CS8618 .. .. 1 @@ -12,9 +12,8 @@ - - - + +