Files
spectre.console/build.cs
Patrik Svensson 45799107a3 Remove Spectre.Console.Cli from repository
* Move Spectre.Console.Cli to its own repository
* Update build script to use Cake.Sdk and .NET Make
* Remove StyleCop (unmaintained)
* Add linting using dotnet format
* Fix generator which was broken
* Update dependencies
2025-11-12 20:56:48 +01:00

111 lines
2.8 KiB
C#

#:sdk Cake.Sdk@5.1.25296.94-beta
var solution = "./src/Spectre.Console.slnx";
var generatorSolution = "./resources/scripts/Generator/Generator.slnx";
var testProject = "./src/Spectre.Console.Tests/Spectre.Console.Tests.csproj";
////////////////////////////////////////////////////////////////
// Arguments
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
////////////////////////////////////////////////////////////////
// Tasks
Task("Clean")
.Does(ctx =>
{
ctx.CleanDirectory("./.artifacts");
});
Task("Lint")
.Does(ctx =>
{
ctx.DotNetFormat(solution, new DotNetFormatSettings
{
VerifyNoChanges = true,
});
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Lint")
.Does(ctx =>
{
ctx.DotNetBuild(solution, new DotNetBuildSettings
{
Configuration = configuration,
Verbosity = DotNetVerbosity.Minimal,
NoLogo = true,
NoIncremental = ctx.HasArgument("rebuild"),
MSBuildSettings = new DotNetMSBuildSettings()
.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error)
});
});
Task("Test")
.IsDependentOn("Build")
.Does(ctx =>
{
ctx.DotNetTest(testProject, new DotNetTestSettings {
Configuration = configuration,
Verbosity = DotNetVerbosity.Minimal,
NoLogo = true,
NoRestore = true,
NoBuild = true,
});
});
Task("Package")
.IsDependentOn("Test")
.Does(ctx =>
{
ctx.DotNetPack(solution, new DotNetPackSettings
{
Configuration = configuration,
Verbosity = DotNetVerbosity.Minimal,
NoLogo = true,
NoRestore = true,
NoBuild = true,
OutputDirectory = "./.artifacts",
MSBuildSettings = new DotNetMSBuildSettings()
.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error)
});
});
Task("Publish-NuGet")
.WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions")
.IsDependentOn("Package")
.Does(ctx =>
{
var apiKey = Argument<string?>("nuget-key", null);
if(string.IsNullOrWhiteSpace(apiKey)) {
throw new CakeException("No NuGet API key was provided.");
}
// Publish to GitHub Packages
foreach(var file in ctx.GetFiles("./.artifacts/*.nupkg"))
{
ctx.Information("Publishing {0}...", file.GetFilename().FullPath);
DotNetNuGetPush(file.FullPath, new DotNetNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = apiKey,
});
}
});
////////////////////////////////////////////////////////////////
// Targets
Task("Publish")
.IsDependentOn("Publish-NuGet");
Task("Default")
.IsDependentOn("Package");
////////////////////////////////////////////////////////////////
// Execution
RunTarget(target);