CliInvoke.Core
2.0.1
Prefix Reserved
See the version list below for details.
dotnet add package CliInvoke.Core --version 2.0.1
NuGet\Install-Package CliInvoke.Core -Version 2.0.1
<PackageReference Include="CliInvoke.Core" Version="2.0.1" />
<PackageVersion Include="CliInvoke.Core" Version="2.0.1" />
<PackageReference Include="CliInvoke.Core" />
paket add CliInvoke.Core --version 2.0.1
#r "nuget: CliInvoke.Core, 2.0.1"
#:package CliInvoke.Core@2.0.1
#addin nuget:?package=CliInvoke.Core&version=2.0.1
#tool nuget:?package=CliInvoke.Core&version=2.0.1
CliInvoke.Core
This package contains Process Running and handling abstractions as well as common types used by implementing classes.
For an implementing package, check out CliInvoke.
Key Abstractions:
IProcessInvokerIProcessConfigurationFactoryPiping:
IProcessPipeHandler
Fluent Builders:
IArgumentsBuilder- An interface to help with Argument Building and argument escaping.IEnvironmentVariablesBuilder- An interface to help with setting Environment variables.IProcessConfigurationBuilder- An interface to fluently configure and buildProcessConfigurationobjects.IProcessResourcePolicyBuilder- An interface to fluently configure and buildProcessResourcePolicyobjects.IUserCredentialBuilder
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 | ✅ | ❌ | ❌ |
Installing CliInvoke.Core
CliInvoke.Core 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 |
|---|---|---|
| CliInvoke.Core | CliInvoke.Core Nuget | dotnet add package CliInvoke.Core |
Supported Platforms
CliInvoke supports Windows, macOS, Linux, FreeBSD, Android, and potentially some other operating systems.
For more details see the list of supported platforms
Examples
Simple ProcessConfiguration creation with Factory Pattern
This approach uses the IProcessConfigurationFactory interface factory to create a ProcessConfiguration. It requires fewer parameters and sets up more defaults for you.
It can be provided with a Action<IProcessConfigurationBuilder> configure optional parameter where greater control 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.Core.Factories;
using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliIinvoke;
using Microsoft.Extensions.DependencyInjection;
// Dependency Injection setup code ommitted for clarity
// Get IProcessConfigurationFactory
IProcessConfigurationFactory processConfigFactory = serviceProvider.GetRequiredService<IProcessConfigurationFactory>();
// Get IProcessConfigurationInvoker
IProcessInvoker _invoker_ = serviceProvider.GetRequiredService<IProcessInvoker>();
// Simply create the process configuration.
ProcessConfiguration configuration = processConfigFactory.Create("path/to/exe", "arguments");
// Run the process configuration and get the results.
ProcessResult result = await _invoker.ExecuteAsync(configuration, CancellationToken.None);
Buffered Execution Example
This example gets a BufferedProcessResult which contains redirected StandardOutput and StandardError as strings.
using AlastairLundy.CliInvoke.Core.Factories;
using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliIinvoke;
using Microsoft.Extensions.DependencyInjection;
// Dependency Injection setup code ommitted for clarity
// Get IProcessConfigurationFactory
IProcessConfigurationFactory processConfigFactory = serviceProvider.GetRequiredService<IProcessConfigurationFactory>();
// Get IProcessConfigurationInvoker
IProcessnvoker _invoker_ = serviceProvider.GetRequiredService<IProcessInvoker>();
// Simply create the process configuration.
ProcessConfiguration configuration = processConfigFactory.Create("path/to/exe", "arguments");
// Run the process configuration and get the results.
BufferedProcessResult result = await _invoker.ExecuteBufferedAsync(configuration, CancellationToken.None);
Advanced Configuration with Builders
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;
using Microsoft.Extensions.DependencyInjection;
//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")
.SetArguments(["arg1", "arg2"])
.SetWorkingDirectory("/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.Builders;
using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Core.Builders;
using Microsoft.Extensions.DependencyInjection;
//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")
.SetArguments(["arg1", "arg2"])
.SetWorkingDirectory("/Path/To/Directory")
.RedirectStandardOutput(true)
.RedirectStandardError(true);
// 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);
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
- Polyfill for simplifying .NET Standard 2.0 support
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
- Microsoft.Bcl.HashCode (>= 6.0.0)
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on CliInvoke.Core:
| Package | Downloads |
|---|---|
|
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. |
|
|
CliInvoke.Specializations
CliInvoke Specializations is a library for providing pre-configured Specializations of CliInvoke's ProcessConfiguration. |
|
|
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.2.0-alpha.2 | 260 | 12/11/2025 |
| 2.2.0-alpha.1 | 613 | 12/1/2025 |
| 2.1.2 | 307 | 12/11/2025 |
| 2.1.1 | 593 | 11/18/2025 |
| 2.1.0 | 347 | 11/14/2025 |
| 2.0.1 | 499 | 11/18/2025 |
| 2.0.0 | 327 | 11/14/2025 |
## Changes since 2.0.0
### Core package
* Update internal Polyfill version from 8.9.1 to 9.1.0
### Main package
* Updated DotExtensions from 8.6.3 to 9.0.0
* Update internal Polyfill version from 8.9.1 to 9.1.0