-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7578869
commit f23cd2e
Showing
75 changed files
with
2,477 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,4 +305,5 @@ __pycache__/ | |
# Project specific | ||
|
||
BuildArtifacts/ | ||
build/tools/* | ||
docs/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,2 @@ | ||
$ErrorActionPreference = 'Stop' | ||
|
||
$SCRIPT_NAME = "recipe.cake" | ||
|
||
Write-Host "Restoring .NET Core tools" | ||
dotnet tool restore | ||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
|
||
Write-Host "Bootstrapping Cake" | ||
dotnet cake $SCRIPT_NAME --bootstrap | ||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
|
||
Write-Host "Running Build" | ||
dotnet cake $SCRIPT_NAME @args | ||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | ||
dotnet run --project build/Build.csproj -- $args | ||
exit $LASTEXITCODE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,2 @@ | ||
#!/bin/bash | ||
SCRIPT_NAME="recipe.cake" | ||
|
||
echo "Restoring .NET Core tools" | ||
dotnet tool restore | ||
|
||
echo "Bootstrapping Cake" | ||
dotnet cake $SCRIPT_NAME --bootstrap | ||
|
||
echo "Running Build" | ||
dotnet cake $SCRIPT_NAME "$@" | ||
dotnet run --project ./build/Build.csproj -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> | ||
|
||
<!-- Make sure start same folder .NET Core CLI and Visual Studio. --> | ||
<!-- Also expected from Cake.Issues.Recipe to have build directory set as working directory. --> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Cake.Codecov" Version="3.0.0" /> | ||
<PackageReference Include="Cake.Frosting" Version="5.0.0" /> | ||
<PackageReference Include="Cake.Frosting.Issues.Recipe" Version="5.1.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Cake.Common; | ||
using Cake.Common.Build; | ||
using Cake.Common.Diagnostics; | ||
using Cake.Common.IO; | ||
using Cake.Common.Tools.GitVersion; | ||
using Cake.Core; | ||
using Cake.Frosting; | ||
using Spectre.Console; | ||
|
||
public class BuildLifetime : FrostingLifetime<BuildContext> | ||
{ | ||
public override void Setup(BuildContext context, ISetupContext info) | ||
{ | ||
AnsiConsole.Write(new FigletText("Cake.Issues").Centered()); | ||
|
||
// Determine version | ||
DetermineVersion(context); | ||
|
||
// Cleanup "dist" folder | ||
context.CleanDirectory(context.Parameters.OutputDirectory); | ||
} | ||
|
||
public override void Teardown(BuildContext context, ITeardownContext info) | ||
{ | ||
} | ||
|
||
private static void DetermineVersion(BuildContext context) | ||
{ | ||
var settings = new GitVersionSettings | ||
{ | ||
ToolPath = context.Tools.Resolve("dotnet-gitversion.exe") | ||
}; | ||
|
||
if (settings.ToolPath == null) | ||
{ | ||
settings.ToolPath = context.Tools.Resolve("dotnet-gitversion"); | ||
} | ||
|
||
if (!context.BuildSystem().IsLocalBuild) | ||
{ | ||
settings.UpdateAssemblyInfo = true; | ||
settings.UpdateAssemblyInfoFilePath = | ||
context.State.RepositoryRootDirectory | ||
.GetRelativePath(context.Paths.SrcDirectoryPath) | ||
.CombineWithFilePath("SolutionInfo.cs"); | ||
} | ||
|
||
context.State.Version = context.GitVersion(settings); | ||
|
||
context.Information("Building version {0}", context.State.Version.FullSemVer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Cake.Core; | ||
|
||
/// <summary> | ||
/// Class holding state during execution of build. | ||
/// </summary> | ||
public class BuildContext : IssuesContext<BuildParameters, BuildState> | ||
{ | ||
public Paths Paths { get; } | ||
|
||
public BuildContext(ICakeContext context) | ||
: base(context) | ||
{ | ||
Paths = new Paths(this); | ||
} | ||
|
||
protected override BuildParameters CreateIssuesParameters() | ||
{ | ||
return new BuildParameters(this); | ||
} | ||
|
||
protected override BuildState CreateIssuesState() | ||
{ | ||
return new BuildState(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Cake.Core; | ||
|
||
public class BuildParameters : IssuesParameters | ||
{ | ||
public CodeCoverageParameters CodeCoverage { get; } | ||
|
||
public MsBuildParameters Build { get; } | ||
|
||
public PackagingParameters Packaging { get; } | ||
|
||
public BuildParameters(ICakeContext context) | ||
{ | ||
this.OutputDirectory = "../BuildArtifacts"; | ||
this.CodeCoverage = new CodeCoverageParameters(context); | ||
this.Build = new MsBuildParameters(context); | ||
this.Packaging = new PackagingParameters(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Cake.Common; | ||
using Cake.Core; | ||
|
||
public class CodeCoverageParameters(ICakeContext context) | ||
{ | ||
public string CodecovRepoToken { get; } = context.EnvironmentVariable("CODECOV_REPO_TOKEN"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Cake.Common.Build; | ||
using Cake.Common.Tools.DotNet.MSBuild; | ||
using Cake.Core; | ||
|
||
public class MsBuildParameters(ICakeContext context) | ||
{ | ||
public string Configuration { get; } = "Release"; // Configuration is also hardcoded in nuspec files | ||
|
||
public DotNetMSBuildSettings GetSettings() | ||
{ | ||
return new DotNetMSBuildSettings() | ||
.SetConfiguration(this.Configuration) | ||
.WithProperty("ContinuousIntegrationBuild", (!context.BuildSystem().IsLocalBuild).ToString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Cake.Common; | ||
using Cake.Core; | ||
|
||
public class PackagingParameters(ICakeContext context) | ||
{ | ||
public string NuGetApiKey { get; } = context.EnvironmentVariable("NUGET_API_KEY"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Cake.Common.IO; | ||
using Cake.Core.IO; | ||
|
||
public class Paths | ||
{ | ||
public FilePath SolutionFilePath { get; } | ||
|
||
public DirectoryPath SrcDirectoryPath { get; } | ||
|
||
public DirectoryPath NuspecDirectoryPath { get; } | ||
|
||
public DirectoryPath OutputLogsDirectoryPath { get; } | ||
|
||
public DirectoryPath OutputPackagesNuGetDirectoryPath { get; } | ||
|
||
public DirectoryPath OutputTestResultsDirectoryPath { get; } | ||
|
||
public Paths(BuildContext context) | ||
{ | ||
this.SrcDirectoryPath = context.State.RepositoryRootDirectory.Combine("src"); | ||
this.NuspecDirectoryPath = context.State.RepositoryRootDirectory.Combine("nuspec").Combine("nuget"); | ||
|
||
this.OutputLogsDirectoryPath = context.Parameters.OutputDirectory.Combine("logs"); | ||
this.OutputPackagesNuGetDirectoryPath = context.Parameters.OutputDirectory.Combine("Packages").Combine("NuGet"); | ||
this.OutputTestResultsDirectoryPath = context.Parameters.OutputDirectory.Combine("TestResults"); | ||
|
||
this.SolutionFilePath = this.SrcDirectoryPath.CombineWithFilePath("Cake.Issues.sln"); | ||
|
||
context.EnsureDirectoryExists(context.Parameters.OutputDirectory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Cake.Common.Tools.GitVersion; | ||
|
||
public class BuildState : IssuesState | ||
{ | ||
public GitVersion Version { get; set; } | ||
|
||
public BuildState(BuildContext context) | ||
: base(context, RepositoryInfoProviderType.CakeGit) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Cake.Core.Packaging; | ||
using Cake.Frosting; | ||
|
||
internal static class ServiceProviderExtensions | ||
{ | ||
public static void InstallTool(this IServiceProvider provider, string packageName, string packageVersion) | ||
{ | ||
var toolInstaller = (IToolInstaller)provider.GetService(typeof(IToolInstaller)); | ||
toolInstaller.Install(new PackageReference($"nuget:?package={packageName}&version={packageVersion}")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Cake.Frosting; | ||
using System.Reflection; | ||
|
||
public static class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
// renovate: depName=GitVersion.Tool | ||
const string nuGetVersion = "6.1.0"; | ||
|
||
return new CakeHost() | ||
.UseContext<BuildContext>() | ||
.UseLifetime<BuildLifetime>() | ||
.AddAssembly(Assembly.GetAssembly(typeof(IssuesTask))) | ||
.InstallTool(new Uri($"dotnet:?package=GitVersion.Tool&version={nuGetVersion}")) | ||
.Run(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.Build; | ||
using Cake.Common.Tools.DotNet.MSBuild; | ||
using Cake.Frosting; | ||
|
||
[TaskName("Build-Solution")] | ||
[IsDependentOn(typeof(RestoreSolutionTask))] | ||
[IsDependeeOf(typeof(ReadIssuesTask))] | ||
public sealed class BuildSolutionTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
var msBuildLogFilePath = context.Paths.OutputLogsDirectoryPath.CombineWithFilePath("build.binlog"); | ||
|
||
var settings = new DotNetBuildSettings | ||
{ | ||
NoRestore = true, | ||
MSBuildSettings = | ||
context.Parameters.Build.GetSettings() | ||
.WithLogger( | ||
"BinaryLogger," + context.Environment.ApplicationRoot.CombineWithFilePath("StructuredLogger.dll"), | ||
"", | ||
msBuildLogFilePath.FullPath) | ||
.WithTarget("Rebuild"), | ||
}; | ||
|
||
context.DotNetBuild(context.Paths.SolutionFilePath.FullPath, settings); | ||
|
||
// Read issues | ||
context.Parameters.InputFiles.AddMsBuildBinaryLogFilePath(msBuildLogFilePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Cake.Frosting; | ||
|
||
[TaskName("Build")] | ||
[IsDependentOn(typeof(BuildSolutionTask))] | ||
public sealed class BuildTask : FrostingTask | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Cake.Common.Build; | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.Restore; | ||
using Cake.Frosting; | ||
|
||
[TaskName("Restore-Solution")] | ||
public sealed class RestoreSolutionTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
// Enforce up to date lock files in CI builds. | ||
// On local builds lock files will be updated if necessary. | ||
var settings = new DotNetRestoreSettings | ||
{ | ||
LockedMode = !context.BuildSystem().IsLocalBuild, | ||
MSBuildSettings = context.Parameters.Build.GetSettings(), | ||
}; | ||
|
||
context.DotNetRestore(context.Paths.SolutionFilePath.FullPath, settings); | ||
} | ||
} |
Oops, something went wrong.