CliWrap offers an immutable, async API around System.Diagnostics.Process with fluent configuration, piping, cancellation, and event-stream execution models.
Overview
CliWrap is a NuGet package for .NET applications that need reliable control over external command-line programs. Commands are immutable values built with a fluent interface for arguments, working directory, environment, and validation behavior.
Execution helpers run processes asynchronously with cancellation support, stdin and stdout piping, graceful interrupt handling, and protection against common deadlock patterns when capturing output. Pipes can chain commands similarly to shell pipelines.
Beyond simple task-based runs, CliWrap can expose execution as an event stream for incremental stdout and stderr handling. It targets .NET Standard 2.0 and newer desktop and core frameworks without extra dependencies, with testing called out on Windows, Linux, and macOS.
Key features
- Immutable command configuration objects
- Async ExecuteAsync with cancellation
- Stdin, stdout, and stderr piping
- Shell-style pipe operator helpers
- Event-stream execution model
- Non-zero exit validation options
- Graceful interrupt signal handling
- Cross-platform .NET targeting
Use cases
- Calling CLI tools from C# services
- Streaming long-running process output
- Building piped command workflows in .NET
- Avoiding deadlocks when capturing stderr