Skip to content

Commit

Permalink
Merge pull request #68 from OctopusDeploy/eoin/pet/net8
Browse files Browse the repository at this point in the history
Use .NET 8 SDK
  • Loading branch information
YuKitsune authored Dec 5, 2023
2 parents 56a94cf + 3ea6495 commit b8ca32e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
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)
Expand Down
41 changes: 20 additions & 21 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,38 +8,39 @@
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
{
const string CiBranchNameEnvVariable = "OCTOVERSION_CurrentBranch";

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;

#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;
readonly string OctoVersionBranch = null!; // assigned by Nuke via reflection
#pragma warning restore CS0414

[Parameter] readonly int? OctoVersionFullSemVer;
[Parameter] readonly string? OctoVersionFullSemVer;
[Parameter] readonly int? OctoVersionMajor;
[Parameter] readonly int? OctoVersionMinor;
[Parameter] readonly int? OctoVersionPatch;

[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";
Expand All @@ -52,9 +51,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 => _ => _
Expand All @@ -70,7 +69,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)
Expand All @@ -96,7 +95,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}");
Expand All @@ -118,7 +117,7 @@ class Build : NukeBuild
.TriggeredBy(Pack)
.Executes(() =>
{
EnsureExistingDirectory(LocalPackagesDir);
LocalPackagesDir.CreateDirectory();
ArtifactsDirectory.GlobFiles("*.nupkg")
.ForEach(package =>
{
Expand Down
9 changes: 6 additions & 3 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<!-- NET8: Remove this when Nuke releases a new version which sets it for us -->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.4.0-mattr-octoversio0017" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
</ItemGroup>

<ItemGroup>
<PackageDownload Include="OctoVersion.Tool" Version="[0.3.49]" />
<PackageDownload Include="Octopus.OctoVersion.Tool" Version="[0.3.293]" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Octopus.Versioning.Tests</AssemblyName>
<PackageId>Octopus.Versioning.Tests</PackageId>
<PackageIconUrl>http://i.octopusdeploy.com/resources/Avatar3_360.png</PackageIconUrl>
Expand Down

0 comments on commit b8ca32e

Please sign in to comment.