SimpleExec 12.0.0

dotnet add package SimpleExec --version 12.0.0
                    
NuGet\Install-Package SimpleExec -Version 12.0.0
                    
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="SimpleExec" Version="12.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleExec" Version="12.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SimpleExec" />
                    
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 SimpleExec --version 12.0.0
                    
#r "nuget: SimpleExec, 12.0.0"
                    
#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.
#addin nuget:?package=SimpleExec&version=12.0.0
                    
Install SimpleExec as a Cake Addin
#tool nuget:?package=SimpleExec&version=12.0.0
                    
Install SimpleExec as a Cake Tool

SimpleExec

SimpleExec

NuGet version

Build status CodeQL analysis lint Spell check

SimpleExec is a .NET library that runs external commands. It wraps System.Diagnostics.Process to make things easier.

SimpleExec intentionally does not invoke the system shell.

Platform support: .NET 6.0 and later.

Quick start

using static SimpleExec.Command;
Run("foo", "arg1 arg2");

Run

Run("foo");
Run("foo", "arg1 arg2");
Run("foo", new[] { "arg1", "arg2" });

await RunAsync("foo");
await RunAsync("foo", "arg1 arg2");
await RunAsync("foo", new[] { "arg1", "arg2" });

By default, the command is echoed to standard output (stdout) for visibility.

Read

var (standardOutput1, standardError1) = await ReadAsync("foo");
var (standardOutput2, standardError2) = await ReadAsync("foo", "arg1 arg2");
var (standardOutput3, standardError3) = await ReadAsync("foo", new[] { "arg1", "arg2" });

Other optional arguments

string workingDirectory = "",
bool noEcho = false,
string? echoPrefix = null,
Action<IDictionary<string, string?>>? configureEnvironment = null,
bool createNoWindow = false,
Encoding? encoding = null,
Func<int, bool>? handleExitCode = null,
string? standardInput = null,
bool cancellationIgnoresProcessTree = false,
CancellationToken cancellationToken = default,

Exceptions

If the command has a non-zero exit code, an ExitCodeException is thrown with an int ExitCode property and a message in the form of:

$"The process exited with code {ExitCode}."

In the case of ReadAsync, an ExitCodeReadException is thrown, which inherits from ExitCodeException, and has string Out and Error properties, representing standard out (stdout) and standard error (stderr), and a message in the form of:

$@"The process exited with code {ExitCode}.

Standard Output:

{Out}

Standard Error:

{Error}"

Overriding default exit code handling

Most programs return a zero exit code when they succeed and a non-zero exit code fail. However, there are some programs which return a non-zero exit code when they succeed. For example, Robocopy returns an exit code less than 8 when it succeeds and 8 or greater when a failure occurs.

The throwing of exceptions for specific non-zero exit codes may be suppressed by passing a delegate to handleExitCode which returns true when it has handled the exit code and default exit code handling should be suppressed, and returns false otherwise.

For example, when running Robocopy, exception throwing should be suppressed for an exit code less than 8:

Run("ROBOCOPY", "from to", handleExitCode: code => code < 8);

Note that it may be useful to record the exit code. For example:

var exitCode = 0;
Run("ROBOCOPY", "from to", handleExitCode: code => (exitCode = code) < 8);

// see https://ss64.com/nt/robocopy-exit.html
var oneOrMoreFilesCopied = exitCode & 1;
var extraFilesOrDirectoriesDetected = exitCode & 2;
var misMatchedFilesOrDirectoriesDetected = exitCode & 4;

<sub>Run by Gregor Cresnar from the Noun Project.</sub>

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on SimpleExec:

Package Downloads
Vertiq.Testing.XUnit

A highly modular framework for writing Blazor applications with a hassle-free, vertical-sliced architecture - Easy. Flexible. Focused.

Xenial.Beer

Beer - Delicious dotnet build tools

Quick.Build

A lot of utils for build.

ZYC.AutomationTools

Package Description

ILVerifier

A simple helper library to access provider-specific types when working with IDbConnection and friends.

GitHub repositories (41)

Showing the top 20 popular GitHub repositories that depend on SimpleExec:

Repository Stars
xunit/xunit
xUnit.net is a free, open source, community-focused unit testing tool for .NET.
aaubry/YamlDotNet
YamlDotNet is a .NET library for YAML
adamhathcock/sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
AppMetrics/AppMetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
gothinkster/aspnetcore-realworld-example-app
ASP.NET Core backend implementation for RealWorld
FakeItEasy/FakeItEasy
The easy mocking library for .NET
ProxyKit/ProxyKit
A toolkit to create code-first HTTP reverse proxies on ASP.NET Core
DuendeArchive/IdentityModel
.NET standard helper library for claims-based identity, OAuth 2.0 and OpenID Connect.
adamralph/minver
🏷 Minimalistic versioning using Git tags.
machine/machine.specifications
Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
DuendeArchive/IdentityModel.OidcClient
Certified C#/NetStandard OpenID Connect Client Library for native mobile/desktop Applications (RFC 8252)
Particular/Workshop
SOA Done Right
JasperFx/lamar
Fast Inversion of Control Tool and Successor to StructureMap
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK.
spectresystems/snitch
A tool that help you find duplicate transitive package references.
SQLStreamStore/SQLStreamStore
Stream Store library targeting RDBMS based implementations for .NET
XamlAnimatedGif/XamlAnimatedGif
A simple library to display animated GIF images in WPF apps (.NET Framework 4.5, .NET Core 3.1, .NET 5.0)
config-r/config-r
Write your .NET configuration files in C#
JasperFx/jasper
Next generation application development framework for .Net
adamralph/xbehave.net
✖ An xUnit.net extension for describing each step in a test with natural language.
Version Downloads Last updated
12.0.0 479,988 1/15/2024
12.0.0-rc.1 423 12/25/2023
12.0.0-beta.1 266 12/24/2023
12.0.0-alpha.1 2,003 6/9/2023
11.0.0 495,694 8/21/2022
11.0.0-rc.1 630 7/22/2022
10.0.0 154,401 3/26/2022
10.0.0-beta.2 20,998 3/20/2022
10.0.0-beta.1 273 3/19/2022
9.1.0 16,821 3/19/2022
9.1.0-rc.1 246 3/13/2022
9.1.0-alpha.1 260 3/12/2022
9.0.0 4,625 3/12/2022
9.0.0-rc.4 1,251 2/26/2022
9.0.0-rc.3 9,845 12/30/2021
9.0.0-rc.2 301 12/23/2021
9.0.0-rc.1 211 12/23/2021
9.0.0-alpha.1 22,923 8/22/2021
8.0.0 657,332 7/5/2021
8.0.0-rc.1 493 6/26/2021
8.0.0-alpha.8 246 6/20/2021
8.0.0-alpha.7 218 6/19/2021
8.0.0-alpha.6 245 6/19/2021
8.0.0-alpha.5 240 6/19/2021
8.0.0-alpha.4 276 6/19/2021
8.0.0-alpha.3 963 6/13/2021
8.0.0-alpha.2 436 6/12/2021
8.0.0-alpha.1 278 6/12/2021
7.0.0 74,937 3/14/2021
7.0.0-alpha.2 353 3/13/2021
7.0.0-alpha.1 4,455 12/20/2020
6.4.0 72,409 12/20/2020
6.4.0-rc.1 1,589 12/5/2020
6.3.0 44,768 10/26/2020
6.2.0 294,239 12/21/2019
6.2.0-rc.1 1,368 12/15/2019
6.1.0 64,922 10/13/2019
6.1.0-rc.1 1,624 9/8/2019
6.1.0-beta.1 870 8/27/2019
6.0.0 55,168 7/13/2019
6.0.0-rc.1 434 6/27/2019
6.0.0-beta.1 676 6/12/2019
6.0.0-alpha.1 467 6/1/2019
5.0.1 20,218 2/10/2019
5.0.1-rc.1 621 2/10/2019
5.0.0 380 2/9/2019
5.0.0-beta.1 971 2/5/2019
5.0.0-alpha.2 360 2/4/2019
5.0.0-alpha.1 655 1/3/2019
4.2.0 17,988 12/8/2018
4.1.0 2,359 12/2/2018
4.0.0 408 11/27/2018
4.0.0-rc.1 439 11/26/2018
4.0.0-beta.1 741 11/20/2018
3.0.0 23,431 9/20/2018
2.3.0 2,435 8/25/2018
2.3.0-beta.1 485 8/11/2018
2.2.0 1,843 6/26/2018
2.1.0 1,628 5/20/2018
2.0.0 1,644 11/12/2017
1.0.0 4,784 11/5/2017