FileBasedApp.Toolkit.SimpleExec 1.4.0

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

FileBasedApp.Toolkit.SimpleExec

Optional SimpleExec integration: fluent command runners, typed path arguments, exit-code handling, JSON output parsing and testable command wrappers.

Use the existing FileBasedApp.Toolkit.SimpleExec namespace. This package references FileBasedApp.Toolkit and SimpleExec, but does not depend on Spectre.

Migration (1.4.0-preview-01)

These types moved from FileBasedApp.Toolkit into this optional package. Add an explicit reference:

<PackageReference Include="FileBasedApp.Toolkit.SimpleExec" Version="1.4.0-preview-01" />

Namespaces remain unchanged, but the assembly move is a binary breaking change. Recompile existing consumers after adding the reference. The core package remains framework-neutral; it no longer brings in SimpleExec.

SimpleExecRunner

The SimpleExecRunner provides a fluent builder API on top of the SimpleExec library for constructing and executing system commands. It supports TruePath types (AbsolutePath, LocalPath) directly as arguments, and can redact secrets from echoed output.

using FileBasedApp.Toolkit.SimpleExec;
using TruePath;

// Basic command execution
await new SimpleExecRunner("dotnet")
    .AddArgument("build")
    .AddArgument("MyProject.csproj")
    .RunAsync();

// Using AddArgumentPair for flag + value combinations
await new SimpleExecRunner("dotnet")
    .AddArgument("pack")
    .AddArgumentPair("-c", "Release")
    .AddArgumentPair("-o", outputPath) // accepts AbsolutePath directly
    .RunAsync();

// With secrets redaction — the API key value is replaced with "***" in echoed output
await new SimpleExecRunner("dotnet")
    .AddArguments("nuget", "push")
    .AddArgument(packagePath)
    .AddArgumentPair("--source", "nuget.org")
    .AddArgumentPair("--api-key", apiKey, isSecret: true)
    .RunAsync();

// Reading command output
var (stdout, stderr) = await new SimpleExecRunner("dotnet")
    .AddArgument("--version")
    .ReadAsync();

// Working directory and environment variables
await new SimpleExecRunner("git")
    .AddArguments("status", "--porcelain")
    .WithWorkingDirectory(repoRoot)
    .WithConfigureEnvironment(env => env["GIT_TERMINAL_PROMPT"] = "0")
    .RunAsync();

// Accept an expected non-zero exit code. `git diff --quiet` returns 1 when
// differences exist, which is an expected result rather than a command failure.
await new SimpleExecRunner("git")
    .AddArguments("diff", "--quiet")
    .WithAcceptedErrorCodes([1])
    .RunAsync();

Exit code 0 remains successful by default and does not need to be listed. Other non-zero exit codes still cause the command to throw. Use WithExitCodeHandler when you need the lower-level handled-exit-code callback instead of a fixed list of accepted codes.

Use HandlesAllErrorCodes() only when every exit code is an expected result; it disables SimpleExec's default non-zero-exit-code failure behavior.

Use the result-returning APIs when the observed exit code or captured output is needed after execution:

var result = await new SimpleExecRunner("git")
    .AddArguments("diff", "--quiet")
    .WithAcceptedErrorCodes([1])
    .ReadEnhancedAsync();

Console.WriteLine(result.ExitCode);
Console.WriteLine(result.StandardOutput);
Console.WriteLine(result.StandardError);

RunWithExitCode() and RunWithExitCodeAsync() return SimpleExecRunResult, which contains ExitCode. ReadEnhancedAsync() returns SimpleExecReadResult, which contains ExitCode, StandardOutput, and StandardError. These methods still honor the configured exit-code policy.

Key types:

  • SimpleExecRunner — the fluent builder. Create with new SimpleExecRunner("command-name"), add arguments, then call Run(), RunAsync(), ReadAsync(), or a result-returning execution method.
  • SimpleExecRunResult / SimpleExecReadResult — result types returned by the exit-code-aware execution methods.
  • ISimpleExecCommandWrapper — an interface wrapping SimpleExec.Command to enable unit testing. The default implementation (SimpleExecCommand) delegates directly to the static Command class.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FileBasedApp.Toolkit.SimpleExec:

Package Downloads
FileBasedApp.Toolkit.Dotnet

Fluent builders and recipes for dotnet CLI commands (pack, nuget push, package search).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 76 11/13/2026

- Update with support for .net sdk 11
         - Spectre integration: add ExtendedCommandSettings.TryGetFiles and TryGetDirectories batch validation for .NET 10 and .NET 11, returning absolute path arrays and aggregating validation errors for multiple candidates.
         - Add predefined-root and single-absolute-root forwarding overloads for batch path validation, with XML documentation.
         - Expose TryGetFile, TryGetFiles, TryGetDirectory, and TryGetDirectories as public static PathUtil helpers in the core package without Spectre dependencies.
         - Retain the protected ExtendedCommandSettings TryGet overloads as backward-compatible wrappers over PathUtil, preserving signatures and caller-argument expressions.
         - Update the file-based app template to call PathUtil directly; add core path-helper and compatibility regression coverage.