ProcessStreamEngine 2.0.0
dotnet add package ProcessStreamEngine --version 2.0.0
NuGet\Install-Package ProcessStreamEngine -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProcessStreamEngine" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProcessStreamEngine" Version="2.0.0" />
<PackageReference Include="ProcessStreamEngine" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProcessStreamEngine --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ProcessStreamEngine, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProcessStreamEngine@2.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProcessStreamEngine&version=2.0.0
#tool nuget:?package=ProcessStreamEngine&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ProcessStreamEngine 2.0
AOT-friendly .NET library for monitoring external process output and driving interactive CLI workflows. Version 2.0 centers on a ProcessSession: one reader per pipe, fan-out to subscribers via bounded channels, and adapters for IAsyncEnumerable, IObservable, regex events, and buffered text.
Features
- ProcessSession — owns the process lifecycle (
IAsyncDisposable), kills on cancel by default, and drains pipes before returning. - Output hub — each subscriber gets an isolated bounded
Channel<OutputLine>withWaitorDropOldestbackpressure. IAsyncEnumerable—session.Output.ReadAllAsync()andProcessRunner.ReadLinesAsync().IObservable—session.Output.Subscribe(observer)without System.Reactive.- Pattern matching — register
OnMatch/Captureon the builder before start; use[GeneratedRegex]for AOT. - Expect —
await session.ExpectAsync(regex)(partial prompts without trailing newline via quiet-period tail emission). - Framing — line mode (CR/LF/CRLF) or NUL mode (
git -z). - Transcript — opt-in exact decoded stdout/stderr via
.KeepTranscript(). - One-shot runs —
ProcessRunner.RunTextAsync,RunTextOrThrowAsync,RunWithStreamsAsync. - No reflection, no Instances —
ProcessStartInfoor an already-startedProcessonly.
Requirements
- .NET 8.0, 9.0, or 10.0
- Marked
<IsAotCompatible>true</IsAotCompatible>for trim/AOT analyzers
Quick start
Session with streaming
using ProcessStreamEngine;
using ProcessStreamEngine.Output;
var startInfo = ProcessRunner.CreateStartInfo("git", ["status", "--short"]);
await using var session = ProcessSessionBuilder.Create(startInfo)
.Capture("branch", new Regex(@"On branch (.+)"), captureGroup: "1")
.KeepTranscript()
.Start();
await foreach (var line in session.Output.ReadAllAsync())
Console.WriteLine($"[{line.Stream}] {line.Text}");
var result = await session.WaitForExitAsync();
Interactive input
await using var session = ProcessSessionBuilder.Create(startInfo)
.Start(); // RedirectStandardInput = true on startInfo when needed
await session.ExpectAsync(new Regex(@">\s*$"));
await session.Input.WriteLineAsync("server 8.8.8.8");
One-shot text
var result = await ProcessRunner.RunTextAsync(startInfo);
// result.ExitCode, result.StandardOutput, result.StandardError
var ok = await ProcessRunner.RunTextOrThrowAsync(startInfo); // throws ProcessExitException when non-zero
Raw byte passthrough
await ProcessRunner.RunWithStreamsAsync(
startInfo,
new ProcessStreamOptions
{
StandardInput = inputStream,
StandardOutput = outputStream,
MonitorStderrAsLines = true
});
Core types
| Type | Role |
|---|---|
ProcessSessionBuilder |
Configure framing, handlers, transcript; call Start(). |
ProcessSession |
Running process + Output / Input + WaitForExitAsync. |
ProcessOutput |
ReadAllAsync, Subscribe, GetCapturedData, ExpectAsync. |
OutputLine |
Text, OutputStream, Sequence, IsComplete. |
ProcessRunner |
Static one-shots, CreateStartInfo, ApplyEnvironment. |
Migration from 1.x
| 1.x | 2.0 |
|---|---|
ProcessStreamEngine class |
ProcessSession via ProcessSessionBuilder |
CreateDeferred / StartMonitoringAsync |
ProcessSessionBuilder.Create(...).Start() |
RegisterEvent / RegisterDataCapture |
Builder .OnMatch / .Capture (pass Regex or string) |
WaitForEventAsync |
session.ExpectAsync(regex) or .OnMatch |
RunTextAsync (static on class) |
ProcessRunner.RunTextAsync |
StdoutText / StdoutLines |
.KeepTranscript() then WaitForExitAsync → ProcessResult.StandardOutput or await foreach |
Instances / IProcessInstance |
Removed — use ProcessStartInfo |
ProcessStreamEngineException (non-zero exit) |
ProcessExitException |
SendInputAsync |
session.Input.WriteLineAsync / WriteAsync |
| net6.0 / net7.0 | net8.0+ only |
Handlers should use Regex instances (including source-generated regex) instead of RegexOptions.Compiled.
Testing
dotnet test Source/ProcessStreamEngine.Tests/ProcessStreamEngine.Tests.csproj
Source/ProcessStreamEngine.AotSmoke validates native publish:
dotnet publish Source/ProcessStreamEngine.AotSmoke/ProcessStreamEngine.AotSmoke.csproj -r win-x64 -c Release
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.