AlastairLundy.CliInvoke
1.6.1.1
Prefix Reserved
See the version list below for details.
dotnet add package AlastairLundy.CliInvoke --version 1.6.1.1
NuGet\Install-Package AlastairLundy.CliInvoke -Version 1.6.1.1
<PackageReference Include="AlastairLundy.CliInvoke" Version="1.6.1.1" />
<PackageVersion Include="AlastairLundy.CliInvoke" Version="1.6.1.1" />
<PackageReference Include="AlastairLundy.CliInvoke" />
paket add AlastairLundy.CliInvoke --version 1.6.1.1
#r "nuget: AlastairLundy.CliInvoke, 1.6.1.1"
#:package AlastairLundy.CliInvoke@1.6.1.1
#addin nuget:?package=AlastairLundy.CliInvoke&version=1.6.1.1
#tool nuget:?package=AlastairLundy.CliInvoke&version=1.6.1.1
CliInvoke
CliInvoke is a library for interacting with Command Line Interfaces and wrapping around executables.
<img src="https://github.com/alastairlundy/CliInvoke/blob/main/.assets/icon.png" width="192" height="192" alt="CliInvoke Logo">
Table of Contents
- Features
- Why CliInvoke?
- Installing CliInvoke
- CliInvoke Examples * Executing Commands
- Contributing to CliInvoke
- Roadmap
- License
- Acknowledgements
Features
- Promotes the single responsibility principle and separation of concerns
- For .NET 8 and newer TFMs CliRunner has few dependencies.
- Compatible with .NET Standard 2.0 <sup>1</sup>
- Dependency Injection extensions to make using it easier.
- Support for specific specializations such as running executables or commands via Windows Powershell or CMD on Windows <sup>2</sup>
- SourceLink support
<sup>1</sup> - Polyfill is a dependency only required for .NET Standard 2.0 users. Microsoft.Bcl.HashCode is a dependency only required for .NET Standard 2.0 users.
<sup>2</sup> - The Specialization library is distributed separately here.
Why use CliInvoke over CliWrap?
- Greater separation of concerns with the Command class - Command Building, Command Running, and Command Pipe handling are moved to separate classes.
- Supports Dependency Injection
- Classes and code follow the Single Responsibility Principle
- No hidden or additional licensing terms are required beyond the source code license.
- No imported C code - This library is entirely written in C#.
- No lock in regarding Piping support
How to install and use CliInvoke
CliInvoke is available on Nuget.
These are the CliInvoke projects:
- CliInvoke - The main CliInvoke package.
- CliInvoke.Extensions
- CliInvoke.Specializations
Installing CliInvoke
CliInvoke'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.CliInvoke | CliInvoke Nuget | dotnet add package AlastairLundy.CliInvoke |
AlastairLundy.CliInvoke.Extensions | AlastairLundy.CliInvoke.Extensions Nuget | dotnet add package AlastairLundy.CliInvoke.Extensions |
AlastairLundy.CliInvoke.Extensibility | AlastairLundy.CliInvoke.Extensibility Nuget | dotnet add package AlastairLundy.CliInvoke.Extensibility |
AlastairLundy.CliInvoke.Specializations | AlastairLundy.CliInvoke.Specializations Nuget | dotnet add package AlastairLundy.CliInvoke.Specializations |
Supported Platforms
CliInvoke can be added to .NET Standard 2.0, .NET 8, or .NET 9 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 planned 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.
Using CliInvoke / Examples
Fluent ProcessConfiguration
building
CliInvoke enables use of a fluent builder style of syntax to easily configure and run Commands.
The following example shows how to configure and build a Command that returns a BufferedProcessResult which contains redirected StandardOutput and StandardError as strings.
using AlastairLundy.CliInvoke;
using AlastairLundy.CliInvoke.Builders.Abstractions;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.Extensions.Processes;
//Namespace and classs code ommitted for clarity
// ServiceProvider and Dependency Injection code ommitted for clarity
ICliCommandInvoker _commandInvoker = serviceProvider.GetRequiredService<ICliCommandInvoker>();
// Fluently configure your Command.
ICliCommandConfigurationBuilder builder = new CliCommandConfigurationBuilder("Path/To/Executable")
.WithArguments(["arg1", "arg2"])
.WithWorkingDirectory("/Path/To/Directory");
// Build it as a CliCommandConfiguration object when you're ready to use it.
CliCommandConfiguration commandConfig = builder.Build();
// Execute the CliCommand through CommandRunner and get the results.
BufferedProcessResult result = await _commandInvoker.ExecuteBufferedAsync(commandConfig);
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.
CliInvoke's Roadmap
CliInvoke aims to make working with Commands and external processes easier.
Whilst an initial set of features are available in version 1, there is room for more features, and for modifications of existing features in future updates.
That being said, all stable releases from 1.0 onwards must be stable and should not contain regressions.
Future updates should aim focus on one or more of the following:
- Improved ease of use
- Improved stability
- New features
- Enhancing existing features
License
CliInvoke is licensed under the MPL 2.0 license. If you modify any of CliInvoke's files then the modified files must be licensed under the MPL 2.0 .
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 (>= 1.6.1)
- AlastairLundy.DotExtensions (>= 8.6.2 && < 9.0.0)
-
net8.0
- AlastairLundy.CliInvoke.Core (>= 1.6.1)
- AlastairLundy.DotExtensions (>= 8.6.2 && < 9.0.0)
-
net9.0
- AlastairLundy.CliInvoke.Core (>= 1.6.1)
- AlastairLundy.DotExtensions (>= 8.6.2 && < 9.0.0)
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 | 37 | 10/19/2025 | |
2.0.0-beta.7 | 112 | 10/15/2025 | |
2.0.0-beta.6 | 128 | 10/14/2025 | |
2.0.0-beta.5 | 139 | 10/11/2025 | |
2.0.0-beta.4 | 109 | 10/9/2025 | |
2.0.0-beta.3 | 118 | 10/5/2025 | |
2.0.0-beta.2 | 166 | 10/1/2025 | |
2.0.0-beta.1 | 145 | 9/27/2025 | |
1.6.1.1 | 344 | 10/14/2025 | |
1.6.1 | 385 | 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 | 193 | 7/30/2025 | |
1.4.5 | 294 | 7/10/2025 | |
1.4.4 | 292 | 7/7/2025 | |
1.4.3 | 267 | 6/23/2025 | |
1.4.1 | 592 | 6/11/2025 | |
1.4.0 | 288 | 6/9/2025 | |
1.3.1 | 345 | 5/23/2025 | |
1.2.0 | 538 | 4/8/2025 | |
1.1.0 | 343 | 3/18/2025 | |
1.0.0 | 426 | 3/2/2025 |
### Changes since 1.6.1
*Note*: Core package is unchanged and so a new version has not been released for it.
### Bug Fixes
* Fixed an issue where ``FilePathResolver`` would fail to correctly resolve a file path
* Fixed several issues where exceptions would be thrown upon exiting a Process
* Fixed an issue where a short running Process could throw an exception if setting Process Resource Policy was attempted