AlastairLundy.Extensions.Processes.Abstractions 2.0.0-preview.2

Prefix Reserved
This is a prerelease version of AlastairLundy.Extensions.Processes.Abstractions.
dotnet add package AlastairLundy.Extensions.Processes.Abstractions --version 2.0.0-preview.2
                    
NuGet\Install-Package AlastairLundy.Extensions.Processes.Abstractions -Version 2.0.0-preview.2
                    
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="AlastairLundy.Extensions.Processes.Abstractions" Version="2.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlastairLundy.Extensions.Processes.Abstractions" Version="2.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="AlastairLundy.Extensions.Processes.Abstractions" />
                    
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 AlastairLundy.Extensions.Processes.Abstractions --version 2.0.0-preview.2
                    
#r "nuget: AlastairLundy.Extensions.Processes.Abstractions, 2.0.0-preview.2"
                    
#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.
#addin nuget:?package=AlastairLundy.Extensions.Processes.Abstractions&version=2.0.0-preview.2&prerelease
                    
Install AlastairLundy.Extensions.Processes.Abstractions as a Cake Addin
#tool nuget:?package=AlastairLundy.Extensions.Processes.Abstractions&version=2.0.0-preview.2&prerelease
                    
Install AlastairLundy.Extensions.Processes.Abstractions as a Cake Tool

AlastairLundy.Extensions.Processes.Abstractions

This package contains Process Running and handling abstractions as well as common types used by implementing classes.

For an implementing package, check out AlastairLundy.Extensions.Processes.

Key Abstractions:

  • IProcessFactory
  • Piping:
    • IProcessPipeHandler
  • Builders:
    • IEnvironmentVariablesBuilder
    • IProcessResourcePolicyBuilder
    • IUserCredentialBuilder

Key Types:

  • Process Results
    • ProcessResult
    • BufferedProcessResult
    • PipedProcessResult - A new type that will see more use in version 2
  • ProcessResourcePolicy
  • UserCredential
  • ProcessConfiguration
  • ProcessResultValidation

NuGet NuGet

Table of Contents

Features

  • Easy to use safe Process Running classes and interfaces
  • Models that help abstract away some of the complicated nature of Process objects
  • Compatible with .NET Standard 2.0 and 2.1 ^1
  • SourceLink support

^1 - Polyfill is a dependency only required for .NET Standard 2.0 and 2.1 users. Microsoft.Bcl.HashCode is a dependency only required for .NET Standard 2.0 users.

How to install and use ProcessExtensions

ProcessExtensions is available on Nuget.

Installing ProcessExtensions

ProcessExtensions's packages can be installed via the .NET SDK CLI, Nuget via your IDE or code editor's package interface, or via the Nuget website.

Package Name Nuget Link .NET SDK CLI command
AlastairLundy.Extensions.Processes AlastairLundy.Extensions.Processes Nuget dotnet add package AlastairLundy.Extensions.Processes

Supported Platforms

ProcessExtensions can be added to any .NET Standard 2.0, .NET Standard 2.1, .NET 8, or .NET 9 supported project.

The following table details which target platforms are supported for running Processes.

Operating System Support Status Notes
Windows Fully Supported ✅
macOS Fully Supported ✅
Mac Catalyst Untested Platform ⚠️ Support for this platform has not been tested but should theoretically work.
Linux Fully Supported ✅
FreeBSD Fully Supported ✅
Android Untested Platform ⚠️ Support for this platform has not been tested but should theoretically work.
IOS Not Supported ❌ Not supported due to Process.Start() not supporting IOS. ^2
tvOS Not Supported ❌ Not supported due to Process.Start() not supporting tvOS ^2
watchOS Not Supported ❌ Not supported due to Process.Start() not supporting watchOS ^3
Browser Not Supported and Not Planned ❌ Not supported due to not being a valid target Platform for executing processes.

^2 - See the Process class documentation for more info.

^3 - Lack of watchOS support is implied by lack of IOS support since watchOS is based on IOS.

Note: This library has not been tested on Android or Tizen.

Examples

One of the main use cases for ProcessExtensions is intended to be safe Process Running.

Safe Process Running

ProcessExtensions offers safe abstractions around Process Running to avoid accidentally not disposing of Processes after they are executed.

IProcessFactory provides for this in

IProcessFactory

IProcessFactory is an interface for enabling easy Process Creation, Running, and Disposal depending on the methods used.

The From method and its overloads provide for easy standalone process creation. The StartNew method provides for creating and starting new processes easily.

The ContinueWhenExitAsync and ContinueWhenExitBufferedAsync methods provide for safe process running, and disposal after a Process has exited.

This example shows how it might be used:

using AlastairLundy.Extensions.Processes.Abstractions;
// Using namespaces for Dependency Injection code ommitted for clarity

      // Dependency Injection setup code ommitted for clarity

    IProcessFactory _processFactory = serviceProvider.GetRequiredService<IProcessFactory>();
    
    // Define processStartInfo here.
    
    Process process1 = _processFactory.From(processStartInfo);
    
    // This process that is returned is a Process that has been started.
    Process process2 = _processFactory.StartNew(processStartInfo);
    
    // Wait for the Process to finish before safely disposing of it.
   ProcessResult result = await processFactory.ContinueWhenExitAsync(process2);
    
        
    ProcessResult result = await _processRunner.ExecuteProcessAsync(process, ProcessResultValidation.None);

Asynchronous methods in IProcessFactory also allow for an optional CancellationToken parameter.

Some overloads for ContinueWhenExitAsync and ContinueWhenExitBufferedAsync allow for specifying ProcessResultValidation.

How to Contribute to ProcessExtensions

Thank you in advance for considering contributing to ProcessExtensions.

Please see the CONTRIBUTING.md file for code and localization contributions.

If you want to file a bug report or suggest a potential feature to add, please check out the GitHub issues page to see if a similar or identical issue is already open. If there is not already a relevant issue filed, please file one here and follow the respective guidance from the appropriate issue template.

Thanks.

License

ProcessExtensions is licensed under the MPL 2.0 license. If you modify any of ProcessExtensions' files then the modified files must be licensed under the MPL 2.0 .

If you use ProcessExtensions in your project please make an exact copy of the contents of ProcessExtensions' LICENSE.txt file available either in your third party licenses txt file or as a separate txt file.

Acknowledgements

Projects

This project would like to thank the following projects for their work:

  • Microsoft.Bcl.HashCode for providing a backport of the HashCode class and static methods to .NET Standard 2.0

For more information, please see the THIRD_PARTY_NOTICES file.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on AlastairLundy.Extensions.Processes.Abstractions:

Package Downloads
AlastairLundy.Extensions.Processes

ProcessExtensions adds much needed abstractions and extensions to Processes and Process Running, to make it easier and safer. ProcessExtensions started as part of CliRunner but is now a separate package, helping other projects besides CliRunner to run processes easily and safely.

AlastairLundy.CliInvoke

CliInvoke is a .NET Library for interacting with Command Line Interfaces, CliInvoke is a library for interacting with Command Line Interfaces and wrapping around executables.

AlastairLundy.Extensions.Processes.DependencyInjection

Enables easier setup of Process Extensions' interfaces for dependency injection when using Microsoft.Extensions.DependencyInjection.

AlastairLundy.CliInvoke.Extensibility

Makes extending CliInvoke, and using custom Command Runners and Command Configurations easier.

AlastairLundy.CliInvoke.Extensions

Adds a ``AddCliInvoke`` Dependency Injection extension method to enable easy CliInvoke setup when using the Microsoft.Extensions.DependencyInjection package.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0-preview.2 112 3/18/2025
2.0.0-preview.1 111 3/17/2025
1.4.2 288 3/18/2025
1.4.1 184 3/16/2025
1.4.0 125 3/16/2025

# Changes since 2.0.0 Preview 1
* Updated ``IProcessFactory`` to simplify interface
* Added missing xml doc comments