AlastairLundy.CliInvoke
2.0.0-beta.7
Prefix Reserved
See the version list below for details.
dotnet add package AlastairLundy.CliInvoke --version 2.0.0-beta.7
NuGet\Install-Package AlastairLundy.CliInvoke -Version 2.0.0-beta.7
<PackageReference Include="AlastairLundy.CliInvoke" Version="2.0.0-beta.7" />
<PackageVersion Include="AlastairLundy.CliInvoke" Version="2.0.0-beta.7" />
<PackageReference Include="AlastairLundy.CliInvoke" />
paket add AlastairLundy.CliInvoke --version 2.0.0-beta.7
#r "nuget: AlastairLundy.CliInvoke, 2.0.0-beta.7"
#:package AlastairLundy.CliInvoke@2.0.0-beta.7
#addin nuget:?package=AlastairLundy.CliInvoke&version=2.0.0-beta.7&prerelease
#tool nuget:?package=AlastairLundy.CliInvoke&version=2.0.0-beta.7&prerelease
CliInvoke
<img src="https://github.com/alastairlundy/CliInvoke/blob/main/.assets/icon.png" width="192" height="192" alt="CliInvoke Logo">
CliInvoke is a .NET library for interacting with Command Line Interfaces and wrapping around executables.
Launch processes, redirect standard input and output streams, await process completion and much more.
Features
- Clear separation of concerns between Process Configuration Builders, Process Configuration Models, and Invokers.
- Supports .NET Standard 2.0, .NET 8 and newer TFMs, and has few dependencies.
- Has Dependency Injection extensions to make using it a breeze.
- Support for specific specializations such as running executables or commands via Windows Powershell or CMD on Windows <sup>1</sup>
- SourceLink support
<sup>1</sup> Specializations library distributed separately.
Why CliInvoke?
Feature | CliInvoke | CliWrap | ProcessX |
---|---|---|---|
Configure and Run External Processes using code written in .NET | ✅ | ✅ | ❌, Uses mixture of .NET and BASH syntax |
No Additional Licensing Terms Required for Use | ✅ | ❌ | ✅ |
Uses only managed .NET code | ✅ | ❌ | ✅ |
Follows Separation of Concerns and the Single Responsibility Principle | ✅ | ❌ | ❌ |
Allows for alternative Process Runners to be specified and/or used | ✅ | ❌ | ❌ |
Supported Platforms
CliInvoke can currently be added to .NET Standard 2.0, .NET 8, or .NET 9 or newer supported projects.
The following table details which target platforms are supported for executing commands via CliInvoke.
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. <sup>3</sup> |
tvOS | Not Supported ❌ | Not supported due to Process.Start() not supporting tvOS <sup>3</sup> |
watchOS | Not Supported ❌ | Not supported due to Process.Start() not supporting watchOS <sup>4</sup> |
Browser | Not Planned ❌ | Not supported due to not being a valid target Platform for executing programs or processes. |
<sup>3</sup> - See the Process class documentation for more info.
<sup>4</sup> - 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
Quickstart
For a simpler way to configure ProcessConfiguration
objects, check out CliInvoke.Extensions
Advanced Configuration with Builders
IProcessInvoker
The following examples shows how to configure and build a ProcessConfiguration
depending on whether Buffering the output is desired.
Non-Buffered Execution Example
This example gets a non buffered ProcessResult
that contains basic process exit code, id, and other information.
using AlastairLundy.CliInvoke;
using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.CliInvoke.Core.Builders;
//Namespace and class code ommitted for clarity
// ServiceProvider and Dependency Injection setup code ommitted for clarity
IProcessInvoker _processConfigInvoker = serviceProvider.GetRequiredService<IProcessInvoker>();
// Fluently configure your Command.
IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder("Path/To/Executable")
.WithArguments(["arg1", "arg2"])
.WithWorkingDirectory("/Path/To/Directory");
// Build it as a ProcessConfiguration object when you're ready to use it.
ProcessConfiguration config = builder.Build();
// Execute the process through ProcessInvoker and get the results.
ProcessResult result = await _processConfigInvoker.ExecuteAsync(config);
Buffered Execution Example
This example gets a BufferedProcessResult
which contains redirected StandardOutput and StandardError as strings.
using AlastairLundy.CliInvoke;
using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.CliInvoke.Core.Builders;
//Namespace and class code ommitted for clarity
// ServiceProvider and Dependency Injection setup code ommitted for clarity
IProcessInvoker _processInvoker = serviceProvider.GetRequiredService<IProcessInvoker>();
// Fluently configure your Command.
IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder("Path/To/Executable")
.WithArguments(["arg1", "arg2"])
.WithWorkingDirectory("/Path/To/Directory");
// Build it as a ProcessConfiguration object when you're ready to use it.
ProcessConfiguration config = builder.Build();
// Execute the process through ProcessInvoker and get the results.
BufferedProcessResult result = await _processInvoker.ExecuteBufferedAsync(config);
How to Build CliInvoke's code
Please see building-cliinvoke.md for how to build CliInvoke from source.
How to Contribute to CliInvoke
Thank you in advance for considering contributing to CliInvoke.
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
CliInvoke is licensed under the MPL 2.0 license. You can learn more about it here
If you use CliInvoke in your project please make an exact copy of the contents of CliInvoke's 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:
For more information, please see the THIRD_PARTY_NOTICES file.
Product | Versions 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 was computed. |
.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. |
-
.NETStandard 2.0
- AlastairLundy.CliInvoke.Core (>= 2.0.0-beta.7)
- AlastairLundy.DotExtensions (>= 8.6.2)
-
net8.0
- AlastairLundy.CliInvoke.Core (>= 2.0.0-beta.7)
- AlastairLundy.DotExtensions (>= 8.6.2)
-
net9.0
- AlastairLundy.CliInvoke.Core (>= 2.0.0-beta.7)
- AlastairLundy.DotExtensions (>= 8.6.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on AlastairLundy.CliInvoke:
Package | Downloads |
---|---|
AlastairLundy.CliInvoke.Extensions
Adds a ``AddCliInvoke`` Dependency Injection extension method to enable easy CliInvoke setup when using the Microsoft.Extensions.DependencyInjection package. |
|
AlastairLundy.CliInvoke.Extensibility
Makes extending CliInvoke, and using custom Command Runners and Command Configurations easier. |
|
AlastairLundy.WCountLib.Providers.wc
This package provides implementations for WCountLib.Abstractions interfaces that use Posix's and Unix's ``wc`` program to perform the calculations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated | |
---|---|---|---|
2.0.0-rc.1 | 0 | 10/19/2025 | |
2.0.0-beta.7 | 108 | 10/15/2025 | |
2.0.0-beta.6 | 124 | 10/14/2025 | |
2.0.0-beta.5 | 138 | 10/11/2025 | |
2.0.0-beta.4 | 108 | 10/9/2025 | |
2.0.0-beta.3 | 118 | 10/5/2025 | |
2.0.0-beta.2 | 165 | 10/1/2025 | |
2.0.0-beta.1 | 145 | 9/27/2025 | |
1.6.1.1 | 310 | 10/14/2025 | |
1.6.1 | 382 | 10/9/2025 | |
1.6.0 | 289 | 10/1/2025 | |
1.5.2 | 451 | 9/16/2025 | |
1.5.1 | 378 | 8/25/2025 | |
1.5.0 | 192 | 7/30/2025 | |
1.4.5 | 294 | 7/10/2025 | |
1.4.4 | 291 | 7/7/2025 | |
1.4.3 | 267 | 6/23/2025 | |
1.4.1 | 591 | 6/11/2025 | |
1.4.0 | 286 | 6/9/2025 | |
1.3.1 | 344 | 5/23/2025 | |
1.2.0 | 536 | 4/8/2025 | |
1.1.0 | 343 | 3/18/2025 | |
1.0.0 | 425 | 3/2/2025 |
## Changes since 2.0.0 Beta 6
### Main package
* Added ``ProcessConfigurationFactory``
* Renamed ``ProcessConfigurationInvoker`` to ``ProcessInvoker``