Skip to content

Commit f23cd2e

Browse files
committed
Switch build to Cake Frosting
1 parent 7578869 commit f23cd2e

File tree

75 files changed

+2477
-357
lines changed

Some content is hidden

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

75 files changed

+2477
-357
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install:
2929
# Build Script #
3030
#---------------------------------#
3131
build_script:
32-
- ps: .\build.ps1 --target=CI
32+
- ps: .\build.ps1 --target=Publish
3333

3434
# Tests
3535
test: off

.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/renovate.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
],
2525
"datasourceTemplate": "nuget",
2626
"versioningTemplate": "nuget"
27+
},
28+
{
29+
"customType": "regex",
30+
"description": "Update NuGet package versions in C# files",
31+
"fileMatch": [
32+
"build/{{arg0}}$",
33+
"src/{{arg1}}$"
34+
],
35+
"matchStrings": [
36+
"// renovate:( datasource=(?<datasource>.*?))? depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?( extractVersion=(?<extractVersion>.*?))?\\s*const string \\w*[vV]ersion = \"(?<currentValue>\\S*)\";\\s?"
37+
],
38+
"datasourceTemplate": "nuget",
39+
"versioningTemplate": "nuget"
2740
}
2841
],
2942
"packageRules": [

.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@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.Codecov" Version="3.0.0" />
15+
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
16+
<PackageReference Include="Cake.Frosting.Issues.Recipe" Version="5.1.1" />
17+
</ItemGroup>
18+
19+
</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+
}

0 commit comments

Comments
 (0)