SimpleExec 8.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package SimpleExec -Version 8.0.0
dotnet add package SimpleExec --version 8.0.0
<PackageReference Include="SimpleExec" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleExec --version 8.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SimpleExec, 8.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleExec as a Cake Addin
#addin nuget:?package=SimpleExec&version=8.0.0

// Install SimpleExec as a Cake Tool
#tool nuget:?package=SimpleExec&version=8.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.

By default, the command is echoed to standard error (stderr) for visibility.

Platform support: .NET Standard 2.0 and later.

Quick start

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

API

Run

Run("foo.exe");
Run("foo.exe", "arg1 arg2", "my-working-directory");

await RunAsync("foo.exe");
await RunAsync("foo.exe", "arg1 arg2", "my-working-directory");

Read

var output1 = Read("foo.exe");
var output2 = Read("foo.exe", "arg1 arg2", "my-working-directory");

var output3 = await ReadAsync("foo.exe");
var output4 = await ReadAsync("foo.exe", "arg1 arg2", "my-working-directory");

Other optional arguments

bool noEcho = false,
string windowsName = null,
string windowsArgs = null,
string logPrefix = null,
Action<IDictionary<string, string>> configureEnvironment = null,
bool createNoWindow = false,
Func<int, bool> handleExitCode = null,
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}."

This behaviour can be overridden 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:

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

Windows

🙄

Sometimes, for whatever wonderful reasons, it's necessary to run a different command on Windows. For example, when running Yarn, some combination of mysterious factors may require that you explicitly run cmd.exe with Yarn as an argument, rather than running Yarn directly. The optional windowsNames and windowsArgs parameters may be used to specify a different command name and arguments for Windows:

Run("yarn", windowsName: "cmd", windowsArgs: "/c yarn");

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

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SimpleExec:

Package Downloads
Xenial.Beer

Beer - Delicious dotnet build tools

Quick.Build

A lot of utils for build.

GitHub repositories (32)

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

Repository Stars
IdentityServer/IdentityServer4
OpenID Connect and OAuth 2.0 Framework for ASP.NET Core
xunit/xunit
xUnit.net is a free, open source, community-focused unit testing tool for the .NET Framework.
AppMetrics/AppMetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
JasperFx/marten
.NET Transactional Document DB and Event Store on PostgreSQL
aaubry/YamlDotNet
YamlDotNet is a .NET library for YAML
Version Downloads Last updated
9.0.0-alpha.1 390 8/22/2021
8.0.0 9,591 7/5/2021
8.0.0-rc.1 327 6/26/2021
8.0.0-alpha.8 100 6/20/2021
8.0.0-alpha.7 69 6/19/2021
8.0.0-alpha.6 90 6/19/2021
8.0.0-alpha.5 98 6/19/2021
8.0.0-alpha.4 125 6/19/2021
8.0.0-alpha.3 818 6/13/2021
8.0.0-alpha.2 295 6/12/2021
8.0.0-alpha.1 115 6/12/2021
7.0.0 32,102 3/14/2021
7.0.0-alpha.2 179 3/13/2021
7.0.0-alpha.1 4,009 12/20/2020
6.4.0 22,546 12/20/2020
6.4.0-rc.1 1,450 12/5/2020
6.3.0 17,786 10/26/2020
6.2.0 128,115 12/21/2019
6.2.0-rc.1 1,211 12/15/2019
6.1.0 40,189 10/13/2019
6.1.0-rc.1 1,498 9/8/2019
6.1.0-beta.1 720 8/27/2019
6.0.0 36,175 7/13/2019
6.0.0-rc.1 310 6/27/2019
6.0.0-beta.1 546 6/12/2019
6.0.0-alpha.1 346 6/1/2019
5.0.1 14,620 2/10/2019
5.0.1-rc.1 484 2/10/2019
5.0.0 222 2/9/2019
5.0.0-beta.1 838 2/5/2019
5.0.0-alpha.2 234 2/4/2019
5.0.0-alpha.1 497 1/3/2019
4.2.0 17,129 12/8/2018
4.1.0 2,139 12/2/2018
4.0.0 226 11/27/2018
4.0.0-rc.1 300 11/26/2018
4.0.0-beta.1 574 11/20/2018
3.0.0 18,574 9/20/2018
2.3.0 1,581 8/25/2018
2.3.0-beta.1 292 8/11/2018
2.2.0 901 6/26/2018
2.1.0 702 5/20/2018
2.0.0 736 11/12/2017
1.0.0 863 11/5/2017