CliInvoke is a .NET library for running and interacting with external
command-line processes. It is built for .NET developers who need to launch
an executable, redirect its standard streams, capture its output, and reason
about its lifetime — without hand-rolling System.Diagnostics.Process for
every project.
Every .NET codebase that shells out to another tool eventually needs the same
things: a way to describe the command, a way to start it, a way to capture
its output, a way to dispose of its handles, and a way to test the code that
does all of that. System.Diagnostics.Process provides the primitives; the
boilerplate — pipe setup, output buffering, exit-code handling, disposal,
thread-safety, cross-platform path lookup — is left to you. CliInvoke
provides the layer on top.
The library targets .NET 10, runs on Windows, macOS,
Linux, and BSD, and ships with first-class dependency-integration helpers
(AddCliInvoke, namespace CliInvoke.Extensions) in the CliInvoke package.
CliInvoke exposes three invocation patterns that cover the spectrum from scripting to long-running process control:
CliRun —
a static façade for one-line command execution. The right entry point when
you just need to run a command and read its output.IProcessInvoker —
an interface for DI-centric applications. Takes a ProcessConfiguration
and returns a typed result, with full support for test doubles and per-call
configuration.IExternalProcess —
a power-user API for granular lifecycle control. Splits start, capture,
and kill into separate calls so you can interact with the process while
it runs.Underneath those patterns sit the capabilities that make the library practical to use day-to-day:
ProcessConfiguration and ProcessExitConfiguration models
with sensible defaults. See the
Configuration guide for the full
reference.SecureString buffer; the
Resource Disposal guide documents
the disposal contract for each one.AddCliInvoke() registers the
invoker, factory, and file-path resolver with the container of your
choice. See
Getting Started.CliInvoke.Specializations.If you are unsure which pattern fits your scenario, the Choosing your Invocation Pattern guide walks through the decision tree and the trade-offs of each option.
Different readers arrive here with different needs. Pick the path that matches yours and follow it in order.
Start with a runnable example, then read the pattern-decision guide.
CliRun command in under five minutes.CliRun, IProcessInvoker,
and IExternalProcess.ProcessConfiguration and ProcessExitConfiguration.You work in a codebase that uses dependency injection and you need to unit-test code that shells out to processes.
IProcessInvoker with your DI container.IProcessInvoker is the right pattern for your scenario.ProcessConfiguration model, the builder lifecycle, and the
default-value reference appendix.You need to interact with the process while it runs — pipe input, monitor output, send signals, or replace components for advanced scenarios.
IExternalProcess factory and lifecycle
API.IExternalProcess.If you know what you need to accomplish but not which page it lives on, jump straight to the relevant guide.
| I want to … | Go to |
|---|---|
| Debug a leak, hang, or wrong exit code | Troubleshooting |
| Tune how a process starts or exits | Configuration |
| Understand the internal data-flow | Architecture |
Pick between CliRun, IProcessInvoker, and IExternalProcess |
Choosing your Invocation Pattern |
| Dispose the Resource-Owning Types correctly | Resource Disposal |
| Install and set up the library | Getting Started · Quickstart |
| Look up a specific API | API Reference |
For a flat index of every page, see the Documentation hub.