From 7b864e7c2dc077d2a04637e6daa829cfa95899fd Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:44:53 +1000 Subject: [PATCH 1/3] Use .NET 8 SDK --- .github/workflows/main.yml | 2 +- build/Build.cs | 37 +++++++++---------- build/_build.csproj | 9 +++-- .../Octopus.Versioning.Tests.csproj | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34e3910..2ab6bae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x # Adjustment is done prior to Nuke build as OCTOVERSION information is included in the result package. - name: Append OCTOVERSION_CurrentBranch with -nightly (for scheduled) diff --git a/build/Build.cs b/build/Build.cs index 2231014..e717a40 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,7 +1,5 @@ using System; -using System.Linq; using Nuke.Common; -using Nuke.Common.CI; using Nuke.Common.Execution; using Nuke.Common.IO; using Nuke.Common.ProjectModel; @@ -10,8 +8,8 @@ using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; using Nuke.Common.Tools.OctoVersion; +using Serilog; -[CheckBuildProjectConfigurations] [UnsetVisualStudioEnvironmentVariables] class Build : NukeBuild { @@ -19,12 +17,12 @@ class Build : NukeBuild readonly Configuration Configuration = Configuration.Release; - [Solution] readonly Solution Solution; + [Solution] readonly Solution Solution = null!; // assigned by Nuke via reflection [Parameter] readonly bool? OctoVersionAutoDetectBranch = NukeBuild.IsLocalBuild; [Parameter("Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable " + CiBranchNameEnvVariable + ".", Name = CiBranchNameEnvVariable)] - readonly string OctoVersionBranch; + readonly string OctoVersionBranch = null!; // assigned by Nuke via reflection [Parameter] readonly int? OctoVersionFullSemVer; [Parameter] readonly int? OctoVersionMajor; @@ -33,15 +31,14 @@ class Build : NukeBuild [Required] [OctoVersion( - AutoDetectBranchParameter = nameof(OctoVersionAutoDetectBranch), - BranchParameter = nameof(OctoVersionBranch), - FullSemVerParameter = nameof(OctoVersionFullSemVer), - MajorParameter = nameof(OctoVersionMajor), - MinorParameter = nameof(OctoVersionMinor), - PatchParameter = nameof(OctoVersionPatch), - Framework = "net6.0")] - - readonly OctoVersionInfo OctoVersionInfo; + AutoDetectBranchMember = nameof(OctoVersionAutoDetectBranch), + BranchMember = nameof(OctoVersionBranch), + FullSemVerMember = nameof(OctoVersionFullSemVer), + MajorMember = nameof(OctoVersionMajor), + MinorMember = nameof(OctoVersionMinor), + PatchMember = nameof(OctoVersionPatch), + Framework = "net8.0")] + readonly OctoVersionInfo OctoVersionInfo = null!; // assigned by Nuke via reflection static AbsolutePath SourceDirectory => RootDirectory / "source"; static AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; @@ -52,9 +49,9 @@ class Build : NukeBuild .Before(Restore) .Executes(() => { - SourceDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults").ForEach(DeleteDirectory); - EnsureCleanDirectory(ArtifactsDirectory); - EnsureCleanDirectory(PublishDirectory); + SourceDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults").ForEach(x => x.DeleteDirectory()); + ArtifactsDirectory.CreateOrCleanDirectory(); + PublishDirectory.CreateOrCleanDirectory(); }); Target Restore => _ => _ @@ -70,7 +67,7 @@ class Build : NukeBuild .DependsOn(Restore) .Executes(() => { - Logger.Info("Building Octopus Versioning v{0}", OctoVersionInfo.FullSemVer); + Log.Information("Building Octopus Versioning v{0}", OctoVersionInfo.FullSemVer); DotNetBuild(_ => _ .SetProjectFile(Solution) @@ -96,7 +93,7 @@ class Build : NukeBuild .Produces(ArtifactsDirectory / "*.nupkg") .Executes(() => { - Logger.Info("Packing Octopus Versioning v{0}", OctoVersionInfo.FullSemVer); + Log.Information("Packing Octopus Versioning v{0}", OctoVersionInfo.FullSemVer); // This is done to pass the data to github actions Console.Out.WriteLine($"::set-output name=semver::{OctoVersionInfo.FullSemVer}"); @@ -118,7 +115,7 @@ class Build : NukeBuild .TriggeredBy(Pack) .Executes(() => { - EnsureExistingDirectory(LocalPackagesDir); + LocalPackagesDir.CreateDirectory(); ArtifactsDirectory.GlobFiles("*.nupkg") .ForEach(package => { diff --git a/build/_build.csproj b/build/_build.csproj index ce42605..1a22a74 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,20 +2,23 @@ Exe - net6.0 + net8.0 CS0649;CS0169 .. .. 1 + + true + enable - + - + diff --git a/source/Octopus.Versioning.Tests/Octopus.Versioning.Tests.csproj b/source/Octopus.Versioning.Tests/Octopus.Versioning.Tests.csproj index 1782574..0e96278 100644 --- a/source/Octopus.Versioning.Tests/Octopus.Versioning.Tests.csproj +++ b/source/Octopus.Versioning.Tests/Octopus.Versioning.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 Octopus.Versioning.Tests Octopus.Versioning.Tests http://i.octopusdeploy.com/resources/Avatar3_360.png From 8d52ebe5838c5f861d529c249f8a823645850d9e Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:48:53 +1000 Subject: [PATCH 2/3] Make OctoVersionFullSemVer a string --- build/Build.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.cs b/build/Build.cs index e717a40..9cc38f0 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -24,7 +24,7 @@ class Build : NukeBuild [Parameter("Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable " + CiBranchNameEnvVariable + ".", Name = CiBranchNameEnvVariable)] readonly string OctoVersionBranch = null!; // assigned by Nuke via reflection - [Parameter] readonly int? OctoVersionFullSemVer; + [Parameter] readonly string? OctoVersionFullSemVer; [Parameter] readonly int? OctoVersionMajor; [Parameter] readonly int? OctoVersionMinor; [Parameter] readonly int? OctoVersionPatch; From 3ea64950951664e7cc64e712b2d092f962a16e97 Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Mon, 27 Nov 2023 08:32:52 +1000 Subject: [PATCH 3/3] Disable warning for OctoVersionBranch --- build/Build.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Build.cs b/build/Build.cs index 9cc38f0..bba0bfe 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -21,8 +21,10 @@ class Build : NukeBuild [Parameter] readonly bool? OctoVersionAutoDetectBranch = NukeBuild.IsLocalBuild; +#pragma warning disable CS0414 // Field assigned but never used [Parameter("Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable " + CiBranchNameEnvVariable + ".", Name = CiBranchNameEnvVariable)] readonly string OctoVersionBranch = null!; // assigned by Nuke via reflection +#pragma warning restore CS0414 [Parameter] readonly string? OctoVersionFullSemVer; [Parameter] readonly int? OctoVersionMajor;