Soenneker.Utils.Process 4.0.1545

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.Process --version 4.0.1545
                    
NuGet\Install-Package Soenneker.Utils.Process -Version 4.0.1545
                    
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="Soenneker.Utils.Process" Version="4.0.1545" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Process" Version="4.0.1545" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Process" />
                    
Project file
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 Soenneker.Utils.Process --version 4.0.1545
                    
#r "nuget: Soenneker.Utils.Process, 4.0.1545"
                    
#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 Soenneker.Utils.Process@4.0.1545
                    
#: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=Soenneker.Utils.Process&version=4.0.1545
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Process&version=4.0.1545
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.Process

Starts, captures, streams, probes, and terminates operating-system processes, with explicit shell-command helpers when shell syntax is required.

Installation

dotnet add package Soenneker.Utils.Process

Quick start

using Soenneker.Utils.Process.Registrars;

services.AddProcessUtilAsSingleton();

Start and capture a process

List<string> lines = await processUtil.Start(
    fileName: "dotnet",
    arguments: "--info",
    workingDirectory: repositoryPath,
    waitForExit: true,
    timeout: TimeSpan.FromSeconds(30),
    cancellationToken: cancellationToken);

string stdout = await processUtil.StartAndGetOutput(
    "git",
    "status --short",
    repositoryPath,
    TimeSpan.FromSeconds(10),
    cancellationToken);

These methods launch the executable directly with UseShellExecute = false; pipes, redirection, globs, and shell operators are not interpreted. Start returns stdout lines and prefixes stderr lines with ERROR: . A nonzero exit, start failure, or capture failure throws InvalidOperationException. StartAndGetOutput returns stdout as one string and includes stderr only in its nonzero-exit exception.

Timeout and requested cancellation kill the process tree on a best-effort basis. Start only captures output when waitForExit: true; with false it returns an empty list after launching and does not retain a process handle. Use StartDetached when the caller needs to manage a running child.

Stream lines

await foreach (string line in processUtil.StreamLines(
    "dotnet",
    arguments: "test",
    workingDirectory: repositoryPath,
    cancellationToken: cancellationToken))
{
    Handle(line);
}

Stdout is yielded unchanged and stderr is prefixed with [stderr] . When both are enabled, their lines are merged in the order observed by separate asynchronous readers, which is not a guaranteed byte-level chronology. Cancellation or stopping enumeration early kills the process tree.

Detached processes

Process? process = await processUtil.StartDetached(new ProcessStartDto
{
    FileName = "worker",
    Arguments = "--listen",
    RedirectStandardOutput = true,
    OutputCallback = line => Handle(line)
}, cancellationToken);

if (process is not null)
{
    // Keep the handle while needed, then dispose it after the process exits.
}

StartDetached returns null when startup fails and logs the failure when enabled. The caller owns the returned Process handle. Canceling the supplied token kills the process tree; it does not dispose the returned handle. Callbacks run on process output event threads and must be thread-safe; callback exceptions are caught and logged.

Shell commands

BashRun executes a complete command through /bin/bash -lc; CmdRun executes through cmd.exe /c. Both log output, throw on nonzero exit, and kill the process tree on requested cancellation. Because the command string is interpreted by a shell, do not concatenate untrusted input into it. Use Start with separately controlled executable and arguments when shell syntax is not required.

Probes and termination

  • CommandExists checks PATH resolution without launching the target; CommandExistsAndRuns also runs its version command and requires exit code zero. Operational failures return false, while requested cancellation propagates. Treat the command name as trusted input because Unix resolution uses Bash.
  • IsRunning is a point-in-time exact process-name check. StartIfNotRunning is a check-then-start convenience, not an atomic cross-process lock.
  • Kill(name) terminates the first exact-name match. KillThatStartWith(prefix) attempts every prefix match. KillByNames applies the exact-name operation to each supplied name.
  • Kill operations are destructive and name matching can include unrelated processes. Prefer retaining the Process returned for a child you started. Access-denied and already-exited failures are treated as best effort by the low-level kill method.

Environment-variable dictionaries are added to the inherited child environment. Avoid logging command lines or values containing credentials; process arguments and environment variables can also be visible to other software on the host.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on Soenneker.Utils.Process:

Package Downloads
Soenneker.Git.Util

Asynchronous Git operations, repository discovery, and bounded batch processing using bundled Git distributions.

Soenneker.Utils.Dotnet

A utility library for the dotnet executable

Soenneker.Compression.SevenZip

A utility library for 7zip compression related operations

Soenneker.Kiota.Util

A utility library for Kiota and OpenAPI related operations

Soenneker.Python.Util

A utility library for python related operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1547 0 9/4/2026
4.0.1546 0 9/4/2026
4.0.1545 56 9/4/2026
4.0.1544 265 9/4/2026
4.0.1543 835 9/4/2026
4.0.1542 446 9/4/2026
4.0.1534 11,089 8/30/2026
4.0.1533 360 8/30/2026
4.0.1532 1,307 8/30/2026
4.0.1531 2,240 8/30/2026
4.0.1530 309 8/30/2026
4.0.1529 200 8/29/2026
4.0.1528 3,489 8/29/2026
4.0.1527 95 8/29/2026
4.0.1526 157 8/29/2026
4.0.1525 16,458 8/26/2026
4.0.1524 1,333 8/25/2026
4.0.1523 4,308 8/21/2026
4.0.1522 7,614 8/18/2026
4.0.1521 2,866 8/18/2026
Loading failed

Updated Multiple NuGet packages