mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-12 23:22:50 +08:00

eg. [CommandOption("-a|--args")] [Description(nameof(Str.GitArgs))] [Localization(typeof(Str))] public string Args { get; set; } The program will go to the autogenerated class "Str.designer.cs" of the Resx file, to looking for local value of the the resource symbol "GitArgs" , instead of displaying the original: "GitArgs"
110 lines
3.2 KiB
C#
110 lines
3.2 KiB
C#
var target = Argument("target", "Default");
|
|
var configuration = Argument("configuration", "Release");
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
// Tasks
|
|
|
|
Task("Clean")
|
|
.Does(context =>
|
|
{
|
|
context.CleanDirectory("./.artifacts");
|
|
});
|
|
|
|
Task("Build")
|
|
.IsDependentOn("Clean")
|
|
.Does(context =>
|
|
{
|
|
Information("Compiling generator...");
|
|
DotNetBuild("./resources/scripts/Generator/Generator.sln", new DotNetBuildSettings {
|
|
Configuration = configuration,
|
|
Verbosity = DotNetVerbosity.Minimal,
|
|
NoLogo = true,
|
|
NoIncremental = context.HasArgument("rebuild"),
|
|
MSBuildSettings = new DotNetMSBuildSettings()
|
|
.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error)
|
|
});
|
|
|
|
Information("\nCompiling Spectre.Console...");
|
|
DotNetBuild("./src/Spectre.Console.sln", new DotNetBuildSettings {
|
|
Configuration = configuration,
|
|
Verbosity = DotNetVerbosity.Minimal,
|
|
NoLogo = true,
|
|
NoIncremental = context.HasArgument("rebuild"),
|
|
MSBuildSettings = new DotNetMSBuildSettings()
|
|
.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error)
|
|
});
|
|
});
|
|
|
|
Task("Test")
|
|
.IsDependentOn("Build")
|
|
.Does(context =>
|
|
{
|
|
DotNetTest("./src/Tests/Spectre.Console.Tests/Spectre.Console.Tests.csproj", new DotNetTestSettings {
|
|
Configuration = configuration,
|
|
Verbosity = DotNetVerbosity.Minimal,
|
|
NoLogo = true,
|
|
NoRestore = true,
|
|
NoBuild = true,
|
|
});
|
|
|
|
DotNetTest("./src/Tests/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj", new DotNetTestSettings {
|
|
Configuration = configuration,
|
|
Verbosity = DotNetVerbosity.Minimal,
|
|
NoLogo = true,
|
|
NoRestore = true,
|
|
NoBuild = true,
|
|
});
|
|
});
|
|
|
|
Task("Package")
|
|
//.IsDependentOn("Test")
|
|
.Does(context =>
|
|
{
|
|
context.DotNetPack($"./src/Spectre.Console.sln", new DotNetPackSettings {
|
|
Configuration = configuration,
|
|
Verbosity = DotNetVerbosity.Minimal,
|
|
NoLogo = true,
|
|
NoRestore = false,
|
|
NoBuild = false,
|
|
OutputDirectory = "./.artifacts",
|
|
MSBuildSettings = new DotNetMSBuildSettings()
|
|
.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error)
|
|
});
|
|
});
|
|
|
|
Task("Publish-NuGet")
|
|
//.WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions")
|
|
.IsDependentOn("Package")
|
|
.Does(context =>
|
|
{
|
|
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 context.GetFiles("./.artifacts/*.nupkg"))
|
|
{
|
|
context.Information("Publishing {0}...", file.GetFilename().FullPath);
|
|
DotNetNuGetPush(file.FullPath, new DotNetNuGetPushSettings
|
|
{
|
|
Source = "https://api.nuget.org/v3/index.json",
|
|
ApiKey = apiKey,
|
|
SkipDuplicate = true
|
|
});
|
|
}
|
|
});
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
// Targets
|
|
|
|
Task("Publish")
|
|
.IsDependentOn("Publish-NuGet");
|
|
|
|
Task("Default")
|
|
.IsDependentOn("Package");
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
// Execution
|
|
|
|
RunTarget(target) |