ForgeTrust.AppSurface.Console
0.1.0-preview.4
dotnet add package ForgeTrust.AppSurface.Console --version 0.1.0-preview.4
NuGet\Install-Package ForgeTrust.AppSurface.Console -Version 0.1.0-preview.4
<PackageReference Include="ForgeTrust.AppSurface.Console" Version="0.1.0-preview.4" />
<PackageVersion Include="ForgeTrust.AppSurface.Console" Version="0.1.0-preview.4" />
<PackageReference Include="ForgeTrust.AppSurface.Console" />
paket add ForgeTrust.AppSurface.Console --version 0.1.0-preview.4
#r "nuget: ForgeTrust.AppSurface.Console, 0.1.0-preview.4"
#:package ForgeTrust.AppSurface.Console@0.1.0-preview.4
#addin nuget:?package=ForgeTrust.AppSurface.Console&version=0.1.0-preview.4&prerelease
#tool nuget:?package=ForgeTrust.AppSurface.Console&version=0.1.0-preview.4&prerelease
ForgeTrust.AppSurface.Console
Modular bootstrapping for .NET Console applications using CliFx.
Overview
ForgeTrust.AppSurface.Console provides a structured way to build command-line tools. It automatically discovers CliFx commands from modules, registers their source-generated CliFx descriptors, runs them inside the .NET Generic Host, and exposes a startup options seam for console-specific behavior such as command-first output.
Release Guidance
AppSurface is preparing the first coordinated v0.1.0 release. Before installing this package from a prerelease feed, read the v0.1 release preview for current release risk, provisional migration guidance, and the finalization path to the tagged release note.
Usage
Create a startup class that inherits from ConsoleStartup<TModule>:
public class MyConsoleStartup : ConsoleStartup<MyRootModule> { }
In your Program.cs:
await ConsoleApp<MyRootModule>.RunAsync(args);
You can also customize console startup behavior at the entry point:
using ForgeTrust.AppSurface.Core;
await ConsoleApp<MyRootModule>.RunAsync(
args,
options =>
{
options.OutputMode = ConsoleOutputMode.CommandFirst;
});
If you are using a custom startup type directly, the same configuration can be applied fluently:
await new MyConsoleStartup()
.WithOptions(options => options.OutputMode = ConsoleOutputMode.CommandFirst)
.RunAsync(args);
Features
- Command Discovery: Automatically finds classes implementing
ICommandfrom the entry point assembly and dependent modules, then registers their CliFx 3 generated command descriptors. - Hosted Runner: Integrates with the .NET Generic Host to manage service lifecycles during command execution.
- Console Options:
ConsoleOptionslets entry points configure shared console behavior before the host is built.
Command authoring with CliFx 3
AppSurface uses CliFx 3 source-generated command descriptors. Command classes keep the normal CliFx attribute model, but the compiler now generates the descriptor AppSurface registers at runtime.
using CliFx;
using CliFx.Binding;
using CliFx.Infrastructure;
[Command("greet", Description = "Prints a greeting.")]
public sealed partial class GreetCommand : ICommand
{
[CommandParameter(0, Description = "The name to greet.")]
public required string Name { get; set; }
public ValueTask ExecuteAsync(IConsole console)
{
console.Output.WriteLine($"Hello, {Name}!");
return ValueTask.CompletedTask;
}
}
- Mark every command class as
partialso CliFx can attach the generatedDescriptorproperty. - If a command is nested, mark each containing type as
partialtoo. - Use
seton command-bound properties. CliFx 3 generated binders assign parsed values after construction. - Use C#
requiredfor required options and parameters. The older CliFxIsRequiredattribute property is not part of CliFx 3. - Keep constructors DI-friendly. AppSurface still resolves command instances from the application service provider.
- For an app-owned
config diagnosticscommand that renders the active AppSurface configuration audit report, use the copy-paste wrapper in ForgeTrust.AppSurface.Config.
ConsoleOptions
ConsoleOptions is the public startup configuration surface for AppSurface console apps.
OutputModedefaults toConsoleOutputMode.Default.ConsoleOutputMode.Defaultpreserves the standard Generic Host experience, including lifecycle output that may appear alongside command output.ConsoleOutputMode.CommandFirstsuppresses ambient host and command-runner lifecycle information so help, validation, and command-owned progress remain the primary console experience.CustomRegistrationsruns after AppSurface's built-in console registrations so advanced hosts and tests can override services such asCliFx.Infrastructure.IConsoleor add extra logging providers.
Use CommandFirst for public CLIs where first-touch output is part of the product surface. Leave the default in place for internal tools or apps where host lifecycle logs are useful operational context.
Pitfalls
CommandFirstsuppresses ambient lifecycle information, not command-owned progress. Your command still needs to log or write the progress messages users should see.- Console options are applied before host creation. Configure them at the entry point or through
WithOptions(...), not inside command handlers. CustomRegistrationsoverrides services late in the startup pipeline. Use it intentionally for host-level customization, not as a replacement for normal module service registration.- If you override console startup behavior in a derived startup class, keep the shared options path intact so entry-point configuration still reaches the host.
- A command without generated CliFx metadata fails during startup with guidance to make the command and any enclosing types
partial.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- CliFx (>= 3.0.0)
- CliWrap (>= 3.10.1)
- ForgeTrust.AppSurface.Core (>= 0.1.0-preview.4)
- Microsoft.Extensions.Hosting (>= 9.0.6)
- Microsoft.Extensions.Logging.Console (>= 9.0.6)
- Microsoft.Extensions.Options (>= 10.0.8)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ForgeTrust.AppSurface.Console:
| Package | Downloads |
|---|---|
|
ForgeTrust.AppSurface.Aspire
ForgeTrust.AppSurface.Aspire package for AppSurface application composition. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.4 | 56 | 5/25/2026 |
| 0.1.0-preview.3 | 57 | 5/20/2026 |
| 0.1.0-preview.2 | 54 | 5/14/2026 |