Skip to content

Commit d6f3636

Browse files
committed
Switch build to Cake Frosting
1 parent 3ce8862 commit d6f3636

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2128
-329
lines changed

.azuredevops/pipelines/templates/stages/build-for-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ stages:
1212
vmImage: 'ubuntu-22.04'
1313
steps:
1414
- template: ../steps/install-required-dotnet-versions-for-building.yml
15-
- bash: ./build.sh --target=Create-NuGet-Packages
15+
- bash: ./build.sh --target=Package
1616
displayName: 'Build'
1717
- publish: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
1818
artifact: NuGet Package

.config/dotnet-tools.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/integrationtests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
8.x
3333
9.x
3434
- name: Build
35-
run: ./build.sh --target=Create-NuGet-Packages
35+
run: ./build.sh --target=Package
3636
shell: bash
3737
- name: Publish NuGet package as build artifact
3838
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,5 @@ __pycache__/
305305
# Project specific
306306

307307
BuildArtifacts/
308+
build/tools/*
308309
docs/.cache/

build.ps1

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
1-
$ErrorActionPreference = 'Stop'
2-
3-
$SCRIPT_NAME = "recipe.cake"
4-
5-
Write-Host "Restoring .NET Core tools"
6-
dotnet tool restore
7-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
8-
9-
Write-Host "Bootstrapping Cake"
10-
dotnet cake $SCRIPT_NAME --bootstrap
11-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
12-
13-
Write-Host "Running Build"
14-
dotnet cake $SCRIPT_NAME @args
15-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
1+
dotnet run --project build/Build.csproj -- $args
2+
exit $LASTEXITCODE;

build.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
#!/bin/bash
2-
SCRIPT_NAME="recipe.cake"
3-
4-
echo "Restoring .NET Core tools"
5-
dotnet tool restore
6-
7-
echo "Bootstrapping Cake"
8-
dotnet cake $SCRIPT_NAME --bootstrap
9-
10-
echo "Running Build"
11-
dotnet cake $SCRIPT_NAME "$@"
2+
dotnet run --project ./build/Build.csproj -- "$@"

build/Build.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
7+
8+
<!-- Make sure start same folder .NET Core CLI and Visual Studio. -->
9+
<!-- Also expected from Cake.Issues.Recipe to have build directory set as working directory. -->
10+
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
15+
<PackageReference Include="Cake.Frosting.Issues.Recipe" Version="5.1.1" />
16+
</ItemGroup>
17+
18+
</Project>

build/BuildLifetime.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Cake.Common;
2+
using Cake.Common.Build;
3+
using Cake.Common.Diagnostics;
4+
using Cake.Common.IO;
5+
using Cake.Common.Tools.GitVersion;
6+
using Cake.Core;
7+
using Cake.Frosting;
8+
using Spectre.Console;
9+
10+
public class BuildLifetime : FrostingLifetime<BuildContext>
11+
{
12+
public override void Setup(BuildContext context, ISetupContext info)
13+
{
14+
AnsiConsole.Write(new FigletText("Cake.Issues").Centered());
15+
16+
// Determine version
17+
DetermineVersion(context);
18+
19+
// Cleanup "dist" folder
20+
context.CleanDirectory(context.Parameters.OutputDirectory);
21+
}
22+
23+
public override void Teardown(BuildContext context, ITeardownContext info)
24+
{
25+
}
26+
27+
private static void DetermineVersion(BuildContext context)
28+
{
29+
var settings = new GitVersionSettings
30+
{
31+
ToolPath = context.Tools.Resolve("dotnet-gitversion.exe")
32+
};
33+
34+
if (settings.ToolPath == null)
35+
{
36+
settings.ToolPath = context.Tools.Resolve("dotnet-gitversion");
37+
}
38+
39+
if (!context.BuildSystem().IsLocalBuild)
40+
{
41+
settings.UpdateAssemblyInfo = true;
42+
settings.UpdateAssemblyInfoFilePath =
43+
context.State.RepositoryRootDirectory
44+
.GetRelativePath(context.Paths.SrcDirectoryPath)
45+
.CombineWithFilePath("SolutionInfo.cs");
46+
}
47+
48+
context.State.Version = context.GitVersion(settings);
49+
50+
context.Information("Building version {0}", context.State.Version.FullSemVer);
51+
}
52+
}

build/Context/BuildContext.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Cake.Core;
2+
3+
/// <summary>
4+
/// Class holding state during execution of build.
5+
/// </summary>
6+
public class BuildContext : IssuesContext<BuildParameters, BuildState>
7+
{
8+
public Paths Paths { get; }
9+
10+
public BuildContext(ICakeContext context)
11+
: base(context)
12+
{
13+
Paths = new Paths(this);
14+
}
15+
16+
protected override BuildParameters CreateIssuesParameters()
17+
{
18+
return new BuildParameters(this);
19+
}
20+
21+
protected override BuildState CreateIssuesState()
22+
{
23+
return new BuildState(this);
24+
}
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Cake.Core;
2+
3+
public class BuildParameters : IssuesParameters
4+
{
5+
public MsBuildParameters MsBuild { get; }
6+
7+
public BuildParameters(ICakeContext context)
8+
{
9+
this.OutputDirectory = "../BuildArtifacts";
10+
this.MsBuild = new MsBuildParameters(context);
11+
}
12+
}

0 commit comments

Comments
 (0)