What's New in v9
v9 is a breaking major release. After v8 stabilized and was used across several projects, a set of recurring lessons accumulated — most of them about defaults. Rather than absorb the changes piecemeal, they are batched into one major version bump (8.x → 9.0), which also serves as the opportunity to move onto the System.CommandLine v3 line.
This article explains what changed and, more importantly, why. For task-level how-to, follow the links in each section.
The theme: the library sets fewer defaults
The unifying idea behind v9 is that a library should provide capabilities, not policies. v8 made several decisions on the consumer's behalf — every CLI got a --verbosity option, logging went to the console, output was ad-hoc. Those are convenient until they are wrong, and when they are wrong they are hard to opt out of. v9 removes the imposed policies and lets each application choose.
1. Clean stdout/stderr by default
What changed: The core library no longer creates the recursive global --verbosity/-v option, and it no longer configures any logging by default. With no setup, a command writes nothing except its own output.
Why: v8 added --verbosity to every command on the assumption that every CLI should emit some logging. That is convenient in enterprise settings where the quickest way to build a CLI is to log to the console — but it is a poor default. A CLI whose job is to produce clean, parseable output should not carry a logging flag it never asked for, nor emit log lines that corrupt its output. In v9 the command owns its output; logging is explicit opt-in.
Impact / migration: Any v8 consumer that relied on the automatic --verbosity option or default console logging must now opt in (see Logging & Verbosity). The VerbosityOption type has been removed.
2. System.CommandLine v3
What changed: The core library moves from System.CommandLine 2.0.2 to 3.0, and now multi-targets netstandard2.1;net10.0 (tracking System.CommandLine's own target frameworks — a netstandard floor for reach plus a modern net10.0 leg). The net10.0 leg is AOT/trim-analyzed (IsAotCompatible).
Why: A major version bump already signals breaking change to consumers, so it is the right moment to adopt the next System.CommandLine line. The move required no changes to Albatross's usage of the System.CommandLine API. System.CommandLine v3 itself ships netstandard2.0 + net10.0; core keeps a netstandard2.1 floor for broad reach and adds a net10.0 leg to match v3's modern target, so the broad-compatibility stance holds.
3. File-based logging in Albatross.CommandLine.Defaults
What changed: WithDefaults() / WithSerilog() now configure Serilog to write to a daily-rolling file under IApplicationPath.LogRoot, with no console sink. The Albatross.Logging dependency was dropped in favor of referencing Serilog directly.
Why: This is the complement of clean-output-by-default. Log lines and command output must not share a stream — mixing them corrupts the output contract for anything parsing it. Sending logs to a file keeps stdout/stderr entirely for the command.
How verbosity works now: The level is no longer a CLI flag. WithSerilog() sets a code baseline (Information + FromLogContext + WithThreadId + the file sink) and then layers ReadFrom.Configuration on top, so a Serilog section in appsettings.json can raise/lower the level, add per-namespace overrides, and add sinks — editable at deploy time without recompiling. Details in Logging & Verbosity and the Defaults Library.
Impact / migration: Register an IApplicationPath (from Albatross.Config) before building the host to control where logs are written; if none is registered, WithSerilog() falls back to a DefaultApplicationPath that logs to a log folder under the application base directory. Change level tuning from -v Debug to a Serilog:MinimumLevel setting.
4. A first-class command output strategy: Albatross.CommandLine.Outputs (new package)
What changed: A new opt-in package formalizes how commands emit results, centered on a CommandOutput / CommandOutput<T> envelope. It is JSON-first, built on System.Text.Json: shared serializer options, a Print / PrintAsync surface (PrintAsync can be interrupted with Ctrl+C), and a reusable --compact option.
Why: Once stdout is clean and logging is off the console, a command's output is its result — routinely piped to jq and fed to LLM/agent tooling as well as read by humans. That makes output a contract, and the package encodes the principles that keep it stable:
- Output is a contract; compaction must be lossless — the moment it changes meaning, it is the wrong lever.
- Drop nulls (present-and-null equals absent) but keep empty arrays/objects and default values, so scripted/AI consumers never have to infer a missing key.
- Shaping belongs to the consumer. The library emits the full canonical output; a caller who wants less pipes
--compactoutput intojqor a similar tool. - Color is free and non-destructive — rendered for a TTY, ANSI stripped when piped.
No built-in query layer, no Newtonsoft. Earlier v9 release candidates shipped a --query option backed by JmesPath.Net, which in turn pulled in Newtonsoft.Json. A year of use showed no one was using --query, while it added a dependency chain and a second JSON stack to the serialization path. Both are removed: QueryOption is gone, Print no longer takes a query expression, and serialization uses System.Text.Json throughout. External tools such as jq cover the shaping use case.
The package also ships a simplified, dependency-light, opt-in GlobalErrorHandler that reports failures through the same CommandOutput envelope on stderr. Details in the Outputs Library.
Why a separate package (not merged into Defaults): Outputs (JSON/Spectre) and Defaults (Serilog/config) are orthogonal opinionated concerns with disjoint, heavy dependency graphs. Merging would force Serilog onto consumers who only want structured output, and vice versa. They are documented as a recommended pairing instead.
5. Opt-in options, never auto-registered
What changed: The library's own cross-cutting options — such as --compact from Outputs — are provided as reusable option types. The consumer decides whether and where to apply them (e.g. [UseOption<CompactOption>], or on a shared base-params class); they are never auto-registered as recursive.
Why: This is the --verbosity lesson generalized: v9 never forces a global/cross-cutting option on consumers. If you want a recursive option, you add it deliberately.
No new API required. Adding a recursive option uses existing extensibility — CommandBuilder.RootCommand is public. Create an Option<T> with Recursive = true and add it to host.CommandBuilder.RootCommand before Parse(). (An early plan floated a dedicated "facility" for this; it turned out to be unnecessary.) See Logging & Verbosity for a worked --verbosity example.
6. Dependency stance: System.CommandLine v3 and Hosting 10.x
What changed: Core moves to System.CommandLine 3.0 and raises Microsoft.Extensions.Hosting/DependencyInjection to 10.x; Albatross.CommandLine.Defaults matches.
Why: Microsoft package references follow the major version of the newest target framework (net10.0), at its latest patch. Holding back at 8.x no longer made sense: .NET 8 reaches end of life in November 2026 and .NET 9 already has, so the runtimes this library targets are moving to 10.x regardless. Moving ahead to 11.x was also rejected — it would raise the dependency floor for every consumer, including net10.0 LTS apps, with no benefit to the library. Trade-off accepted: because core still ships the netstandard2.1 leg, a net8/net9 consumer resolving that asset is pulled up to Hosting 10.x — acceptable given those runtimes are EOL/near-EOL. Core builds clean on both the netstandard2.1 and net10.0 legs with Hosting 10.x (which still ships a netstandard-compatible asset).
7. Lightweight host startup
What changed: CommandHost builds its container from a bare new HostBuilder() instead of Host.CreateDefaultBuilder(). The DI scope created for the command is now disposed along with the host.
Why: The host is only ever built, never started — it serves purely as the DI container. Ctrl+C cancellation comes from System.CommandLine (ProcessTerminationTimeout), not the host's console lifetime, which only engages on StartAsync. Everything else CreateDefaultBuilder adds is a policy this release removes: console/debug/event-log logging providers (which wrote log lines to stdout for apps without WithDefaults(), contradicting section 1), appsettings.json loaded from the current working directory with a file watcher, environment-variable configuration, and Development-only DI validation. Dropping it roughly halves container startup (≈190 ms → ≈100 ms, 53 → 29 loaded assemblies in a cold-start measurement).
This also fixes a latent bug: CreateDefaultBuilder turned on ValidateOnBuild when DOTNET_ENVIRONMENT=Development, and that check rejects the conditional-registration pattern (registering a service only for the command being run). Any app using that pattern failed every command at startup in Development, while working in every other environment. DI validation is therefore deliberately not turned back on by default; ValidateScopes alone would add little when there is one scope per process.
Impact / migration: Apps using WithDefaults() / WithConfig() see no difference — those already load configuration from the application directory. Apps that read IConfiguration without WithConfig() must call it (or add sources through ConfigureHost). To restore DI validation, call ConfigureHost(b => b.UseDefaultServiceProvider(o => { ... })).
Migration checklist (v8 → v9)
- [ ] Remove any reliance on the automatic
--verbosity/-voption orCommandBuilder.VerbosityOption. - [ ] If you want logging, add
Albatross.CommandLine.Defaultsand callWithDefaults(appPath.ConfigRoot). Register anIApplicationPathto control where logs are written, or rely on theDefaultApplicationPathfallback. Logs now go to a file, not the console. - [ ] Move log-level tuning from the command line to a
Serilog:MinimumLevelsection inappsettings.json. - [ ] If you print structured results, adopt
Albatross.CommandLine.Outputs(CommandOutput+Print/PrintAsync+--compact) instead of ad-hocConsole.WriteLine. Output is serialized withSystem.Text.Json, so annotate your result types withSystem.Text.Json.Serializationattributes, not Newtonsoft ones. - [ ] If you adopted
--queryfrom an earlier v9 release candidate, remove[UseOption<QueryOption>]and theJmesPathExpressionproperty, callPrint(compact)without the expression, and shape output withjqinstead. - [ ] Verify your build against System.CommandLine 3.0. If you use the System.CommandLine API directly, check it against the 3.0 release notes.
- [ ] If you referenced
Albatross.CommandLine.CodeGendirectly, remove that package reference — the source generator is now bundled intoAlbatross.CommandLine, so referencing the core package is enough (keeping both would double-load the generator).Albatross.CommandLine.CodeAnalysisstays an opt-in package you add explicitly. - [ ] Note that core now pulls in
Microsoft.Extensions.Hosting10.x; a .NET 8/9 app referencing core will get Hosting 10.x transitively. - [ ] If you read
IConfiguration(appsettings.json, environment variables) without callingWithConfig()/WithDefaults(), add that call —CommandHostno longer loads configuration implicitly.