Skip to content

Commit

Permalink
Merge pull request #1 from hexagram-solutions/dotnet-8
Browse files Browse the repository at this point in the history
Update to .NET 8
  • Loading branch information
esond authored Jan 24, 2024
2 parents cc3e221 + 6f525b4 commit 606caa7
Show file tree
Hide file tree
Showing 25 changed files with 108 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"nuke.globaltool": {
"version": "6.3.0",
"version": "8.0.0",
"commands": [
"nuke"
]
Expand Down
9 changes: 3 additions & 6 deletions Hexagrams.Nuke.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagrams.Nuke.Components",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{0C7A72F0-C1C0-4FFC-AE9A-F5C6F41A5780}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{5E407C1E-91BD-4615-B3FD-42692957EA4D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DFE985A6-4EFE-4F30-BF2A-70ACE7A84369}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagrams.Nuke.Components.Tests", "tests\Components\Hexagrams.Nuke.Components.Tests.csproj", "{4B74BF65-FC73-44B1-898D-F1120C3CA5A9}"
Expand All @@ -35,17 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagrams.Nuke.Samples.Form
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3-test", "3-test", "{B693A7E4-A142-464A-8204-417EAACB0BC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "samples\3-test\build\_build.csproj", "{829052B3-CDD4-425E-BA90-E945341FD8B0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "samples\3-test\build\_build.csproj", "{829052B3-CDD4-425E-BA90-E945341FD8B0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{28F6AFEF-11C6-440E-B8C7-F10B04A73BFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hexagrams.Nuke.Samples.Test.Library", "samples\3-test\src\Library\Hexagrams.Nuke.Samples.Test.Library.csproj", "{E79B7FDC-EF9F-44E6-A9E6-6A479CC2F171}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagrams.Nuke.Samples.Test.Library", "samples\3-test\src\Library\Hexagrams.Nuke.Samples.Test.Library.csproj", "{E79B7FDC-EF9F-44E6-A9E6-6A479CC2F171}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{633CC995-9E2C-4C48-AFF5-9B0D758F1F48}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{36F03329-B994-4674-A694-84273B9B329B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hexagrams.Nuke.Samples.Test.Library.Tests", "samples\3-test\tests\Library\Hexagrams.Nuke.Samples.Test.Library.Tests\Hexagrams.Nuke.Samples.Test.Library.Tests.csproj", "{80E6F931-00D7-4A9E-9897-29D24CEA1DF3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagrams.Nuke.Samples.Test.Library.Tests", "samples\3-test\tests\Library\Hexagrams.Nuke.Samples.Test.Library.Tests\Hexagrams.Nuke.Samples.Test.Library.Tests.csproj", "{80E6F931-00D7-4A9E-9897-29D24CEA1DF3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -97,7 +95,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6532F8B0-D1AF-4D8F-9D61-C8337111A76D} = {383918FC-A660-4AD2-AC36-4A93CF286BD2}
{0C7A72F0-C1C0-4FFC-AE9A-F5C6F41A5780} = {5E407C1E-91BD-4615-B3FD-42692957EA4D}
{4B74BF65-FC73-44B1-898D-F1120C3CA5A9} = {DFE985A6-4EFE-4F30-BF2A-70ACE7A84369}
{E147AEBA-DF13-4E32-9641-0F16600CF9A5} = {FC75C64E-A9C0-428A-B28A-EFD563DA13B7}
{FF1BFFCF-4DC0-478F-9151-90F4FBA4AD54} = {E147AEBA-DF13-4E32-9641-0F16600CF9A5}
Expand Down
20 changes: 9 additions & 11 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@
GitHubActionsImage.UbuntuLatest,
GitHubActionsImage.MacOsLatest,
FetchDepth = 0,
OnPullRequestBranches = new[] { "main" },
OnPushBranches = new[] { "main", "release/v*" },
OnPullRequestBranches = ["main"],
OnPushBranches = ["main", "release/v*"],
PublishArtifacts = true,
InvokedTargets = new[] { nameof(ITest.Test) },
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj" })]
InvokedTargets = [nameof(ITest.Test)],
CacheKeyFiles = ["global.json", "src/**/*.csproj"])]
// TODO: Package signing
[GitHubActions(
"release",
GitHubActionsImage.UbuntuLatest,
FetchDepth = 0,
OnPushTags = new[] { "v*" },
OnPushTags = ["v*"],
PublishArtifacts = true,
InvokedTargets = new[] { nameof(ITest.Test), nameof(IPack.Pack), nameof(IPush.Push) },
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj" },
ImportSecrets = new[] { nameof(IPush.NuGetApiKey) })]
partial class Build
{
}
InvokedTargets = [nameof(ITest.Test), nameof(IPack.Pack), nameof(IPush.Push)],
CacheKeyFiles = ["global.json", "src/**/*.csproj"],
ImportSecrets = [nameof(IPush.NuGetApiKey)])]
partial class Build;
8 changes: 4 additions & 4 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ partial class Build : NukeBuild,

public bool RunFormatAnalyzers => true;

Target ICompile.Compile => _ => _
Target ICompile.Compile => t => t
.Inherit<ICompile>()
.DependsOn<IFormat>(x => x.VerifyFormat);

bool IReportCoverage.CreateCoverageHtmlReport => true;

IEnumerable<Project> ITest.TestProjects => Partition.GetCurrent(Solution.GetAllProjects("*.Tests"));

Configure<DotNetPublishSettings> ICompile.PublishSettings => _ => _
.When(!ScheduledTargets.Contains(((IPush) this).Push), _ => _
Configure<DotNetPublishSettings> ICompile.PublishSettings => t => t
.When(!ScheduledTargets.Contains(((IPush) this).Push), s => s
.ClearProperties());

Target IPush.Push => _ => _
Target IPush.Push => t => t
.Inherit<IPush>()
.Consumes(this.FromComponent<IPush>().Pack)
.Requires(() => this.FromComponent<IHasGitRepository>().GitRepository.Tags.Any())
Expand Down
4 changes: 2 additions & 2 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
<PackageDownload Include="GitVersion.Tool" version="[5.12.0]" />
<PackageDownload Include="ReportGenerator" Version="[5.1.18]" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.408",
"version": "8.0.101",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion samples/1-basic/build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class Build : NukeBuild, ICompile
readonly Solution Solution;
Solution IHasSolution.Solution => Solution;

Target ICompile.Compile => _ => _
Target ICompile.Compile => t => t
.Inherit<ICompile>();
}
4 changes: 2 additions & 2 deletions samples/1-basic/build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion samples/2-format/build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Build : NukeBuild, IFormat, ICompile

public IEnumerable<AbsolutePath> ExcludedFormatPaths => Enumerable.Empty<AbsolutePath>();

Target ICompile.Compile => _ => _
Target ICompile.Compile => t => t
.Inherit<ICompile>()
.DependsOn<IFormat>(x => x.VerifyFormat);
}
4 changes: 2 additions & 2 deletions samples/2-format/build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions samples/3-test/build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
<PackageDownload Include="ReportGenerator" Version="[5.1.19]" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
Expand All @@ -17,11 +17,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="ReportGenerator" Version="5.1.23" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="ReportGenerator" Version="5.2.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
8 changes: 6 additions & 2 deletions src/Components/Hexagrams.Nuke.Components.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Components/IClean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public interface IClean : IHasSolution
/// <summary>
/// Clean the current solution with <c>dotnet clean</c>.
/// </summary>
Target Clean => _ => _
Target Clean => t => t
.Description("Clean the solution and build artifacts")
.Before<IRestore>()
.Executes(() =>
{
DotNetClean(_ => _
DotNetClean(s => s
.SetProject(Solution));

if (CleanArtifactsDirectory && this is IHasArtifacts hasArtifacts)
Expand Down
32 changes: 16 additions & 16 deletions src/Components/ICompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,70 @@ public interface ICompile : IRestore, IClean, IHasConfiguration
/// <summary>
/// Compile the solution with <c>dotnet build</c>.
/// </summary>
Target Compile => _ => _
Target Compile => t => t
.Description("Compile the solution")
.DependsOn(Clean)
.DependsOn(Restore)
.WhenSkipped(DependencyBehavior.Skip)
.Executes(() =>
{
ReportSummary(_ => _
.WhenNotNull(this as IHasVersioning, (_, o) => _
ReportSummary(d => d
.WhenNotNull(this as IHasVersioning, (x, o) => x
.AddPair("Version", o!.Versioning.FullSemVer)));

DotNetBuild(_ => _
DotNetBuild(s => s
.Apply(CompileSettingsBase)
.Apply(CompileSettings));

DotNetPublish(_ => _
DotNetPublish(s => s
.Apply(PublishSettingsBase)
.Apply(PublishSettings)
.CombineWith(PublishConfigurations, (_, v) => _.SetProject((string) v.Project)
.CombineWith(PublishConfigurations, (x, v) => x.SetProject((string) v.Project)
.SetFramework(v.Framework)),
PublishDegreeOfParallelism);
});

/// <summary>
/// Settings for controlling compilation behavior.
/// </summary>
sealed Configure<DotNetBuildSettings> CompileSettingsBase => _ => _
sealed Configure<DotNetBuildSettings> CompileSettingsBase => t => t
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.When(IsServerBuild, _ => _
.When(IsServerBuild, s => s
.EnableContinuousIntegrationBuild())
.SetNoRestore(SucceededTargets.Contains(Restore))
.WhenNotNull(this as IHasGitRepository, (_, o) => _
.WhenNotNull(this as IHasGitRepository, (s, o) => s
.SetRepositoryUrl(o!.GitRepository.HttpsUrl))
.WhenNotNull(this as IHasVersioning, (_, o) => _
.WhenNotNull(this as IHasVersioning, (s, o) => s
.SetAssemblyVersion(o!.Versioning.AssemblySemVer)
.SetFileVersion(o.Versioning.AssemblySemFileVer)
.SetInformationalVersion(o.Versioning.InformationalVersion));

/// <summary>
/// Settings for controlling publish behavior.
/// </summary>
sealed Configure<DotNetPublishSettings> PublishSettingsBase => _ => _
sealed Configure<DotNetPublishSettings> PublishSettingsBase => t => t
.SetConfiguration(Configuration)
.EnableNoBuild()
.EnableNoLogo()
.When(IsServerBuild, _ => _
.When(IsServerBuild, s => s
.EnableContinuousIntegrationBuild())
.WhenNotNull(this as IHasGitRepository, (_, o) => _
.WhenNotNull(this as IHasGitRepository, (s, o) => s
.SetRepositoryUrl(o!.GitRepository.HttpsUrl))
.WhenNotNull(this as IHasVersioning, (_, o) => _
.WhenNotNull(this as IHasVersioning, (s, o) => s
.SetAssemblyVersion(o!.Versioning.AssemblySemVer)
.SetFileVersion(o.Versioning.AssemblySemFileVer)
.SetInformationalVersion(o.Versioning.InformationalVersion));

/// <summary>
/// Additional settings for controlling the <c>dotnet build</c> command.
/// </summary>
Configure<DotNetBuildSettings> CompileSettings => _ => _;
Configure<DotNetBuildSettings> CompileSettings => t => t;

/// <summary>
/// Additional settings for controlling the <c>dotnet publish</c> command.
/// </summary>
Configure<DotNetPublishSettings> PublishSettings => _ => _;
Configure<DotNetPublishSettings> PublishSettings => t => t;

/// <summary>
/// The publish configurations to build with.
Expand Down
4 changes: 2 additions & 2 deletions src/Components/IFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface IFormat : IHasSolution
/// <summary>
/// Verify code style preferences using <c>dotnet format</c>.
/// </summary>
Target VerifyFormat => _ => _
Target VerifyFormat => t => t
.Description("Verify code formatting for the solution.")
.TryBefore<ICompile>()
.Executes(() =>
Expand All @@ -51,7 +51,7 @@ public interface IFormat : IHasSolution
/// <summary>
/// Apply code style preferences using <c>dotnet format</c>.
/// </summary>
Target Format => _ => _
Target Format => t => t
.Executes(() =>
{
DotNet($"format whitespace {Solution.Path} " +
Expand Down
Loading

0 comments on commit 606caa7

Please sign in to comment.