Skip to content

Commit 64e9915

Browse files
authored
Better documentation readmes for some projects (#101)
* Update README.md: Rewrite and expand documentation for `CreativeCoders.Core` library - Reworked structure and added detailed feature explanations. - Included code examples for key functionalities, such as parameter validation, collections, thread-safety, caching, string utilities, reflection, and more. - Improved usage instructions, feature descriptions, and added installation steps for better onboarding. * Move `README.md` to `CreativeCoders.Core` folder to align with project structure. * Add `README.md` for `CreativeCoders.Cli` with detailed documentation and examples - Introduced a comprehensive `README.md` covering installation, usage, and key features of the `CreativeCoders.Cli` framework. - Provided examples for commands, options, groups, dependency injection, and customization. - Enhanced XML documentation across the CLI codebase for better API clarity and IDE support. Updated solution/project to include the `README.md`. * Add `README.md` for `CreativeCoders.CakeBuild` with comprehensive documentation - Introduced a detailed `README.md` explaining features, installation, setup, and usage for the `CreativeCoders.CakeBuild` library. - Included code examples for fluent builder usage, custom build contexts, task configuration, GitHub Actions integration, and tool installation. - Added task descriptions, settings interface documentation, and a sample project reference for better onboarding and adoption. * Update `README.md`: Replace `ReportGenerator` tool with `dotnet-reportgenerator-globaltool`
1 parent 375e647 commit 64e9915

54 files changed

Lines changed: 1784 additions & 122 deletions

File tree

Some content is hidden

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

Core.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ EndProject
233233
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessUtilsSampleApp", "samples\ProcessUtilsSampleApp\ProcessUtilsSampleApp.csproj", "{58E94E6E-9A9A-4E3F-ACB5-89E47CE67C39}"
234234
EndProject
235235
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cli", "Cli", "{CDCF2469-1668-4EB0-A73F-692115CF6776}"
236+
ProjectSection(SolutionItems) = preProject
237+
source\Cli\README.md = source\Cli\README.md
238+
EndProjectSection
236239
EndProject
237240
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.Cli.Core", "source\Cli\CreativeCoders.Cli.Core\CreativeCoders.Cli.Core.csproj", "{4E628A1A-953A-4274-B4EF-F33E943A650D}"
238241
EndProject
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# CreativeCoders.CakeBuild
2+
3+
A reusable build automation framework built on [Cake Frosting](https://cakebuild.net/docs/running-builds/runners/cake-frosting) for .NET projects. Provides a fluent builder API with pre-built CI/CD tasks — clean, build, test, pack, publish, create GitHub releases, and more — so you can set up a complete build pipeline with minimal code.
4+
5+
## Features
6+
7+
- 🏗️ **Fluent Builder API** — Configure your build pipeline with `CakeHostBuilder` in just a few lines
8+
- 📦 **Pre-built Tasks** — Standard CI/CD tasks out of the box: Clean, Restore, Build, Test, Pack, Publish, NuGet Push, Code Coverage, GitHub Releases, Distribution Packages
9+
- ⚙️ **Settings Interfaces** — Customize task behavior by implementing strongly-typed settings interfaces
10+
- 🔍 **Auto-Discovery** — Automatically finds Git root, solution files, and test projects
11+
- 🏷️ **GitVersion Integration** — Semantic versioning via GitVersion with static fallback
12+
- 🐙 **GitHub Actions Support** — Log grouping and build server integration
13+
14+
## Getting Started
15+
16+
### Prerequisites
17+
18+
- [.NET 10 SDK](https://dotnet.microsoft.com/download) or later
19+
20+
### Setup
21+
22+
Create a new console application and reference the `CreativeCoders.CakeBuild` package:
23+
24+
```xml
25+
<Project Sdk="Microsoft.NET.Sdk">
26+
<PropertyGroup>
27+
<OutputType>Exe</OutputType>
28+
<TargetFramework>net10.0</TargetFramework>
29+
</PropertyGroup>
30+
31+
<ProjectReference Include="CreativeCoders.CakeBuild" Version="LATEST" />
32+
</Project>
33+
```
34+
35+
### Minimal Example
36+
37+
```csharp
38+
using CreativeCoders.CakeBuild;
39+
40+
CakeHostBuilder.Create()
41+
.UseBuildContext<MyBuildContext>()
42+
.AddDefaultTasks()
43+
.AddBuildServerIntegration()
44+
.InstallTools(
45+
new DotNetToolInstallation("GitVersion.Tool", "6.5.1"),
46+
new DotNetToolInstallation("dotnet-reportgenerator-globaltool", "5.5.1"))
47+
.Build()
48+
.Run(args);
49+
```
50+
51+
## Usage
52+
53+
### Custom Build Context
54+
55+
Extend `CakeBuildContext` and implement the settings interfaces for the tasks you want to configure:
56+
57+
```csharp
58+
public class MyBuildContext(ICakeContext context) : CakeBuildContext(context),
59+
IDefaultTaskSettings,
60+
ICreateDistPackagesTaskSettings
61+
{
62+
public string Copyright => $"{DateTime.Now.Year} My Company";
63+
64+
public string PackageProjectUrl => "https://github.com/my-org/my-repo";
65+
66+
public string PackageLicenseExpression => PackageLicenseExpressions.Apache20;
67+
68+
public string NuGetFeedUrl => "https://api.nuget.org/v3/index.json";
69+
70+
public IEnumerable<DistPackage> DistPackages =>
71+
[
72+
new("my-app-linux-x64", "artifacts/publish/my-app/linux-x64", DistPackageFormat.TarGz),
73+
new("my-app-win-x64", "artifacts/publish/my-app/win-x64", DistPackageFormat.Zip)
74+
];
75+
}
76+
```
77+
78+
### Available Tasks
79+
80+
All default tasks are registered via `AddDefaultTasks()` and execute in dependency order:
81+
82+
| Task | Description | Depends On |
83+
|------|-------------|------------|
84+
| **Clean** | Removes `bin/`, `obj/`, and artifact directories ||
85+
| **Restore** | Restores NuGet packages | Clean |
86+
| **Build** | Builds the solution with version info from GitVersion | Restore |
87+
| **Test** | Runs tests with optional code coverage collection | Build |
88+
| **CodeCoverage** | Generates coverage reports via ReportGenerator | Test |
89+
| **Pack** | Creates NuGet packages with metadata | Build |
90+
| **NuGetPush** | Pushes packages to a NuGet feed | Pack |
91+
| **Publish** | Publishes applications to output directories | Build |
92+
| **CreateDistPackages** | Creates `.tar.gz` / `.zip` distribution archives | Publish |
93+
| **CreateGitHubRelease** | Creates a GitHub release with assets via Octokit ||
94+
95+
### Settings Interfaces
96+
97+
Each task reads its configuration from a settings interface. Implement only the ones you need:
98+
99+
| Interface | Configures |
100+
|-----------|------------|
101+
| `ICleanTaskSettings` | Directories to clean |
102+
| `ITestTaskSettings` | Test projects, coverage options |
103+
| `ICodeCoverageTaskSettings` | Report types and file patterns |
104+
| `IPackTaskSettings` | Package output, metadata (URL, license, copyright) |
105+
| `INuGetPushTaskSettings` | Feed URL, API key, skip flag |
106+
| `IPublishTaskSettings` | Per-project publish configuration (runtime, self-contained) |
107+
| `ICreateDistPackagesTaskSettings` | Distribution package definitions and output path |
108+
| `ICreateGitHubReleaseTaskSettings` | Release metadata, assets, GitHub token |
109+
110+
> [!TIP]
111+
> Implement `IDefaultTaskSettings` to get all standard settings interfaces in one go.
112+
113+
### Tool Installation
114+
115+
Register external tools via the builder:
116+
117+
```csharp
118+
CakeHostBuilder.Create()
119+
.InstallTools(
120+
new DotNetToolInstallation("GitVersion.Tool", "6.5.1"),
121+
new DotNetToolInstallation("dotnet-reportgenerator-globaltool", "5.5.1"))
122+
// ...
123+
```
124+
125+
### GitHub Actions Integration
126+
127+
Enable log grouping for GitHub Actions:
128+
129+
```csharp
130+
CakeHostBuilder.Create()
131+
.AddBuildServerIntegration()
132+
// ...
133+
```
134+
135+
This registers task setup/teardown hooks that create collapsible log groups in GitHub Actions.
136+
137+
### Generic Task Templates
138+
139+
For advanced scenarios, use the generic task templates (`BuildTask<T>`, `TestTask<T>`, etc.) with a custom context type instead of the default `CakeBuildContext`:
140+
141+
```csharp
142+
[TaskName("Build")]
143+
[IsDependentOn(typeof(RestoreTask<MyContext>))]
144+
public class MyBuildTask : BuildTask<MyContext> { }
145+
```
146+
147+
## Sample
148+
149+
See [`samples/CakeBuildSample`](../../../samples/CakeBuildSample) for a complete working example that demonstrates the full pipeline setup with custom context, publishing, and distribution package creation.

source/Cli/CreativeCoders.Cli.Core/CliCommandAttribute.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,34 @@
22

33
namespace CreativeCoders.Cli.Core;
44

5+
/// <summary>
6+
/// Marks a class as a CLI command and specifies the command path used to invoke it.
7+
/// </summary>
8+
/// <param name="commands">The command path segments used to invoke this command.</param>
59
[AttributeUsage(AttributeTargets.Class)]
610
public class CliCommandAttribute(string[] commands) : Attribute
711
{
12+
/// <summary>
13+
/// Gets or sets the display name of the command.
14+
/// </summary>
15+
/// <value>The display name of the command. The default is <see cref="string.Empty"/>.</value>
816
public string Name { get; set; } = string.Empty;
917

18+
/// <summary>
19+
/// Gets the command path segments used to invoke this command.
20+
/// </summary>
21+
/// <value>An array of strings representing the command path.</value>
1022
public string[] Commands { get; } = Ensure.NotNull(commands);
1123

24+
/// <summary>
25+
/// Gets or sets the description of the command displayed in help output.
26+
/// </summary>
27+
/// <value>The description text. The default is <see cref="string.Empty"/>.</value>
1228
public string Description { get; set; } = string.Empty;
1329

30+
/// <summary>
31+
/// Gets or sets the alternative command path segments that can also invoke this command.
32+
/// </summary>
33+
/// <value>An array of alternative command path segments. The default is an empty array.</value>
1434
public string[] AlternativeCommands { get; init; } = [];
1535
}

source/Cli/CreativeCoders.Cli.Core/CliCommandContext.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
namespace CreativeCoders.Cli.Core;
44

5+
/// <summary>
6+
/// Provides the default implementation of <see cref="ICliCommandContext"/>.
7+
/// </summary>
58
[PublicAPI]
69
public class CliCommandContext : ICliCommandContext
710
{
11+
/// <inheritdoc />
812
public string[] AllArgs { get; set; } = [];
913

14+
/// <inheritdoc />
1015
public string[] OptionsArgs { get; set; } = [];
1116
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
namespace CreativeCoders.Cli.Core;
22

3+
/// <summary>
4+
/// Defines a command group that organizes related CLI commands under a common path.
5+
/// </summary>
6+
/// <param name="commands">The command path segments that identify this group.</param>
7+
/// <param name="description">The description of the command group displayed in help output.</param>
38
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
49
public class CliCommandGroupAttribute(string[] commands, string description) : Attribute
510
{
11+
/// <summary>
12+
/// Gets the command path segments that identify this group.
13+
/// </summary>
14+
/// <value>An array of strings representing the group command path.</value>
615
public string[] Commands { get; } = commands;
716

17+
/// <summary>
18+
/// Gets the description of the command group displayed in help output.
19+
/// </summary>
20+
/// <value>The description text.</value>
821
public string Description { get; } = description;
922
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
namespace CreativeCoders.Cli.Core;
22

3+
/// <summary>
4+
/// Specifies when a CLI pre-processor or post-processor should be executed.
5+
/// </summary>
36
public enum CliProcessorExecutionCondition
47
{
8+
/// <summary>
9+
/// The processor is executed for every CLI invocation.
10+
/// </summary>
511
Always,
12+
13+
/// <summary>
14+
/// The processor is executed only when help output is displayed.
15+
/// </summary>
616
OnlyOnHelp,
17+
18+
/// <summary>
19+
/// The processor is executed only when a CLI command is run.
20+
/// </summary>
721
OnlyOnCommand
822
}

source/Cli/CreativeCoders.Cli.Core/CliResult.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22

33
namespace CreativeCoders.Cli.Core;
44

5+
/// <summary>
6+
/// Represents the result of a CLI application execution.
7+
/// </summary>
8+
/// <param name="exitCode">The exit code of the CLI execution.</param>
59
[PublicAPI]
610
public class CliResult(int exitCode)
711
{
12+
/// <summary>
13+
/// Gets or sets the exit code of the CLI execution.
14+
/// </summary>
15+
/// <value>The exit code.</value>
816
public int ExitCode { get; set; } = exitCode;
917
}

source/Cli/CreativeCoders.Cli.Core/CommandResult.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,31 @@ public class CommandResult
1313
/// </summary>
1414
public static CommandResult Success { get; } = new CommandResult();
1515

16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="CommandResult"/> class with an exit code of 0.
18+
/// </summary>
1619
public CommandResult() { }
1720

21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="CommandResult"/> class with the specified exit code.
23+
/// </summary>
24+
/// <param name="exitCode">The exit code for the command result.</param>
1825
public CommandResult(int exitCode)
1926
{
2027
ExitCode = exitCode;
2128
}
2229

30+
/// <summary>
31+
/// Gets the exit code of the command execution.
32+
/// </summary>
33+
/// <value>The exit code. The default is 0.</value>
2334
public int ExitCode { get; init; }
2435

36+
/// <summary>
37+
/// Implicitly converts an integer exit code to a <see cref="CommandResult"/>.
38+
/// </summary>
39+
/// <param name="exitCode">The exit code to convert.</param>
40+
/// <returns>A <see cref="CommandResult"/> representing the exit code. Returns <see cref="Success"/> if the exit code is 0.</returns>
2541
public static implicit operator CommandResult(int exitCode)
2642
=> exitCode == 0
2743
? Success
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
namespace CreativeCoders.Cli.Core;
22

3+
/// <summary>
4+
/// Defines a CLI command that accepts options of type <typeparamref name="TOptions"/>.
5+
/// </summary>
6+
/// <typeparam name="TOptions">The type of the options passed to the command.</typeparam>
37
public interface ICliCommand<in TOptions>
48
where TOptions : class
59
{
10+
/// <summary>
11+
/// Executes the CLI command asynchronously with the specified options.
12+
/// </summary>
13+
/// <param name="options">The options for the command.</param>
14+
/// <returns>A <see cref="CommandResult"/> representing the outcome of the command execution.</returns>
615
Task<CommandResult> ExecuteAsync(TOptions options);
716
}
817

18+
/// <summary>
19+
/// Defines a CLI command without options.
20+
/// </summary>
921
public interface ICliCommand
1022
{
23+
/// <summary>
24+
/// Executes the CLI command asynchronously.
25+
/// </summary>
26+
/// <returns>A <see cref="CommandResult"/> representing the outcome of the command execution.</returns>
1127
Task<CommandResult> ExecuteAsync();
1228
}

source/Cli/CreativeCoders.Cli.Core/ICliPostProcessor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
22

33
namespace CreativeCoders.Cli.Core;
44

5+
/// <summary>
6+
/// Defines a post-processor that executes after a CLI command has completed.
7+
/// </summary>
58
[PublicAPI]
69
public interface ICliPostProcessor
710
{
11+
/// <summary>
12+
/// Executes the post-processor asynchronously with the result of the CLI command.
13+
/// </summary>
14+
/// <param name="cliResult">The result of the CLI command execution.</param>
15+
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
816
Task ExecuteAsync(CliResult cliResult);
917

18+
/// <summary>
19+
/// Gets the condition that determines when this post-processor is executed.
20+
/// </summary>
21+
/// <value>One of the enumeration values that specifies the execution condition.</value>
1022
CliProcessorExecutionCondition ExecutionCondition { get; }
1123
}

0 commit comments

Comments
 (0)