Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .NET 8 SDK #68

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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@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)
Expand Down
39 changes: 18 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,37 @@
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using Nuke.Common.Tools.OctoVersion;
using Serilog;

[CheckBuildProjectConfigurations]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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;

[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

Check warning on line 25 in build/Build.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Build.OctoVersionBranch' is assigned but its value is never used
YuKitsune marked this conversation as resolved.
Show resolved Hide resolved

[Parameter] readonly int? OctoVersionFullSemVer;
[Parameter] readonly string? OctoVersionFullSemVer;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one caught me by surprise. After upgrading, Nuke started to complain about this. Weird that it wasn't doing it before.

[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 +49,9 @@
.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 +67,7 @@
.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 +93,7 @@
.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 +115,7 @@
.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
Loading