🏃 A .NET library that runs external commands.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SimpleExec
SimpleExecTester
SimpleExecTests
assets
.editorconfig
.gitattributes
.gitignore
LICENSE
NuGet.config
README.md
SimpleExec.sln
appveyor.yml
build.cmd
build.sh

README.md

SimpleExec

nuget build

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.

The command is echoed to standard error (stderr) for visibility.

Platform support: .NET Standard 1.3 and upwards.

Quick start

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

API

Each method has:

  • One mandatory parameter: string name.
  • Three optional parameters: string args, string workingDirectory, and bool noEcho.

Run

Run("foo.exe");
Run("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

await RunAsync("foo.exe");
await RunAsync("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

Read

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

var output3 = ReadAsync("foo.exe");
var output4 = ReadAsync("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

Exceptions

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

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

Run by Gregor Cresnar from the Noun Project.