AlastairLundy.CliInvoke.Specializations 2.0.0-beta.2

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

CliInvoke.Specializations

This readme covers the CliInvoke Specializations library. Looking for the CliInvoke Readme?

NuGet NuGet

Usage

CliInvoke.Specializations comes with 3 specializations as of 1.0.0:

  • CmdProcessConfiguration - An easier way to execute processes and commands through cmd.exe (Only supported on Windows)
  • ClassicPowershellProcessConfiguration - An easier way to execute processes and commands through Windows Powershell (Only supported on Windows)
  • PowershellProcessConfiguration - An easier way to execute processes and commands through the modern Cross-Platform open source Powershell (Powershell is not installed by CliInvoke and is expected to be installed if you plan to use it.)

All Command specialization classes come with an already configured TargetFilePath that points to the relevant executable.

CmdProcessConfiguration

The CmdProcessConfiguration TargetFilePath points to Windows' copy of cmd.exe .

using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.CliInvoke.Core.Builders;
using AlastairLundy.CliInvoke.Core.Extensibility;

using AlastairLundy.CliInvoke.Specializations.Configurations;
using AlastairLundy.CliInvoke.Specializations;

    // ServiceProvider and Dependency Injection code ommitted for clarity
    
    IProcessInvoker _processInvoker = serviceProvider.GetRequiredService<IProcessInvoker>();
  IRunnerProcessCreator _runnerProcessCreator = serviceProvider.GetRequiredService<IRunnerProcessCreator>();
  
  //Build your command fluently
  IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder(
          new CmdProcessConfiguration("Your arguments go here"))
                .WithWorkingDirectory(Environment.SystemDirectory);
  
  ProcessConfiguration config = builder.Build();
  
  ProcessConfiguration processToRun = _runnerProcessCreator.CreateRunnerProcess(config);
  
  BufferedProcessResult result = await _processInvoker.ExecuteBufferedAsync(processToRun);

If the result of the command being run is not of concern you can call ExecuteAsync() instead of ExecuteBufferedAsync() and ignore the returned ProcessResult like so:

using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.CliInvoke.Core.Builders;
using AlastairLundy.CliInvoke.Core.Extensibility;

using AlastairLundy.CliInvoke.Specializations.Configurations;
using AlastairLundy.CliInvoke.Specializations;

    // ServiceProvider and Dependency Injection code ommitted for clarity
    
    IProcessInvoker _processInvoker = serviceProvider.GetRequiredService<IProcessInvoker>();
  IRunnerProcessCreator _runnerProcessCreator = serviceProvider.GetRequiredService<IRunnerProcessCreator>();
  
  //Build your command fluently
  IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder(
          new CmdProcessConfiguration("Your arguments go here"))
                .WithWorkingDirectory(Environment.SystemDirectory);
  
  ProcessConfiguration config = builder.Build();
  
  ProcessConfiguration processToRun = _runnerProcessCreator.CreateRunnerProcess(config);
  
  ProcessResult result = await _processInvoker.ExecuteAsync(processToRun);

ClassicPowershellProcessConfiguration

The ClassicPowershellCommand is a specialized Command class with an already configured TargetFilePath that points to Windows' copy of powershell.exe .

using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.CliInvoke.Core.Builders;
using AlastairLundy.CliInvoke.Core.Extensibility;

using AlastairLundy.CliInvoke.Specializations.Configurations;
using AlastairLundy.CliInvoke.Specializations;

    // ServiceProvider and Dependency Injection code ommitted for clarity
    
    IProcessInvoker _processInvoker = serviceProvider.GetRequiredService<IProcessInvoker>();
  IRunnerProcessCreator _runnerProcessCreator = serviceProvider.GetRequiredService<IRunnerProcessCreator>();
  
  //Build your command fluently
  IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder(
          new ClassicPowershellProcessConfiguration("Your arguments go here"))
                .WithWorkingDirectory(Environment.SystemDirectory);
  
  ProcessConfiguration config = builder.Build();
  
  ProcessConfiguration processToRun = _runnerProcessCreator.CreateRunnerProcess(config);
  
  BufferedProcessResult result = await _processInvoker.ExecuteBufferedAsync(processToRun);

PowershellProcessConfiguration

The PowershellProcessConfiguration's TargetFilePath points to the installed copy of cross-platform Powershell if it is installed.

using AlastairLundy.CliInvoke.Core;
using AlastairLundy.CliInvoke.Builders;
using AlastairLundy.CliInvoke.Core.Builders;
using AlastairLundy.CliInvoke.Core.Extensibility;

using AlastairLundy.CliInvoke.Specializations.Configurations;
using AlastairLundy.CliInvoke.Specializations;

    // ServiceProvider and Dependency Injection code ommitted for clarity
    
    IProcessInvoker _processInvoker = serviceProvider.GetRequiredService<IProcessInvoker>();
  IRunnerProcessCreator _runnerProcessCreator = serviceProvider.GetRequiredService<IRunnerProcessCreator>();
  
  //Build your command fluently
  IProcessConfigurationBuilder builder = new ProcessConfigurationBuilder(
          new PowershellProcessConfiguration("Your arguments go here"))
                .WithWorkingDirectory(Environment.SystemDirectory);
  
  ProcessConfiguration config = builder.Build();
  
  ProcessConfiguration processToRun = _runnerProcessCreator.CreateRunnerProcess(config);
  
  BufferedProcessResult result = await _processInvoker.ExecuteBufferedAsync(processToRun);

Licensing

CliInvoke and CliInvoke Specializations are licensed under the MPL 2.0 license. If you modify any of CliInvoke's or CliInvoke.Specialization's files then the modified files must be licensed under the MPL 2.0 .

If you use CliInvoke or CliInvoke.Specializations 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.

Product Compatible and additional computed target framework versions.
.NET 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. 
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
2.0.0-beta.2 61 10/1/2025
2.0.0-beta.1 52 9/27/2025
2.0.0-alpha.8 114 9/25/2025
2.0.0-alpha.7 241 9/15/2025
2.0.0-alpha.6 145 8/25/2025
2.0.0-alpha.5 198 8/7/2025
2.0.0-alpha.4 150 8/4/2025
2.0.0-alpha.3 47 7/19/2025
1.6.0 66 10/1/2025
1.5.2 292 9/16/2025
1.5.1 162 8/25/2025
1.4.5 164 7/10/2025
1.4.4 168 7/7/2025
1.4.3 174 6/23/2025
1.4.1 327 6/11/2025
1.3.1 137 5/23/2025
1.3.0 170 5/19/2025
1.2.1 185 5/19/2025
1.2.0 198 4/8/2025
1.1.0 177 3/20/2025
1.0.0 157 3/2/2025

Updated to CliInvoke 2.0.0 Beta 2