AlastairLundy.ProcessInvoke.Abstractions 1.5.0.1

Prefix Reserved
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package AlastairLundy.ProcessInvoke.Abstractions --version 1.5.0.1
                    
NuGet\Install-Package AlastairLundy.ProcessInvoke.Abstractions -Version 1.5.0.1
                    
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.ProcessInvoke.Abstractions" Version="1.5.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlastairLundy.ProcessInvoke.Abstractions" Version="1.5.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AlastairLundy.ProcessInvoke.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.ProcessInvoke.Abstractions --version 1.5.0.1
                    
#r "nuget: AlastairLundy.ProcessInvoke.Abstractions, 1.5.0.1"
                    
#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 AlastairLundy.ProcessInvoke.Abstractions@1.5.0.1
                    
#: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=AlastairLundy.ProcessInvoke.Abstractions&version=1.5.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AlastairLundy.ProcessInvoke.Abstractions&version=1.5.0.1
                    
Install as a Cake Tool

AlastairLundy.ProcessInvoke.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.ProcessInvoke.

Key Abstractions:

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

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.

When should I use ProcessInvoke vs CliInvoke?

Use CliInvoke IF any of the following apply:

  • You want to programatically execute a Cli Application
  • You want to get the output of a Cli Application.
  • You want to Pipe the Input or Output of a Cli Application.

Use ProcessInvoke IF ALL the following apply:

  • You don't care about getting a Process's Standard Output.
  • You're focussed more on starting and/or stopping Processes.
  • You don't need Argument Building or Escaping capabilities

Note: Whilst ProcessInvoke is capable of doing most of what CliInvoke is capable of, they are intended for different use cases.

CliInvoke internally uses ProcessInvoke but provides additional abstractions around programatically executing programs and is designed specifically for this task.

How to install and use ProcessInvoke.Abstractions

ProcessInvoke.Abstractions is available on Nuget.

Installing ProcessInvoke.Abstractions

ProcessInvoke.Abstractions' 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.ProcessInvoke.Abstractions AlastairLundy.ProcessInvoke.Abstractions Nuget dotnet add package AlastairLundy.ProcessInvoke.Abstractionss

Supported Platforms

ProcessInvoke.Abstractions 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 ProcessInvoke.Abstractions is intended to be safe Process Running.

Safe Process Running

ProcessInvoke.Abstractions 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.ProcessInvoke.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

Thank you in advance for considering contributing to ProcessInvoke.

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

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

If you use ProcessInvoke.Abstractions in your project, please make an exact copy of the contents of ProcessInvoke.Abstractions' 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.  net10.0 was computed.  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. 
.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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated

* Added missing IProcessRunnerUtility interface