FileBasedApp.Toolkit 0.17.0-rc-01

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

FileBasedApp.Toolkit

A collection of opinionated helpers and extensions for building file-based applications in .NET.

Features

  • Provides a PathUtil class for working with paths and validating string paths
  • Provides an IO class to provide methods and extension methods for TruePath
    • FindInFiles — filter files by stream predicate or regex (with ByLine / AllText strategies)
    • Replace — in-place file text transformation
    • SafeDeleteDirectory — safely delete directories with optional exception handling
  • Provides StringExtensions with StringJoin, IsNullOrWhitespace, and IsNullOrEmpty convenience methods
  • Provides an extension of the CommandSettings from the Spectre.Console.Cli providing validation of file and directory paths
  • Provides a SimpleExecRunner fluent builder for constructing and executing system commands via the SimpleExec library, with support for secrets redaction and TruePath integration
  • Includes the following libraries
    • TruePath
    • SimpleExec
    • Spectre.Console.Cli
    • TestableIO.System.IO.Abstractions.Wrappers
    • TruePath.TestableIO.System.IO

Example

Extended settings

The example below shows how to use the ExtendedCommandSettings class to validate file and directory paths.

using FileBasedApp.Toolkit;
using Spectre.Console;
using Spectre.Console.Cli;
using TruePath;

public class CustomCommandSettings : ExtendedCommandSettings
{
    [CommandArgument(0, "<directory-path>")]
    public string? Directory { get; set; }
    
    [CommandOption("--filePath")]
    public required string File { get; set; }

    public AbsolutePath DirectoryPath { get; set; }
    
    public AbsolutePath FilePath { get; set; }
    
    protected override ValidationResult DoValidate()
    {
        // Evaluates the directory string.
        DirectoryPath = TryGetDirectory(Directory,
            allowEmpty: true,
            shouldExist: true,
            PredefinedRootPath.ExecutionFolder);
        FilePath = TryGetFile(File, true, roots: [PathUtil.GetCurrentWorkingFolder(), PathUtil.GetExecutionFolder()]);
        return base.DoValidate();
    }
}

TruePath IO extensions

using System.IO.Abstractions;
using FileBasedApp.Toolkit;

var applicationData = Environment.SpecialFolder.ApplicationData.GetSpecialFolder();
applicationData.FindRequiredParent(x => x.FileName == "SomeValue");
var ancestors = applicationData.GetAncestors(true).ToList();

// Combining with TruePath.TestableIO.System.IO
// This was orignally part of the FileBased.Toolkit library but moved
// to it's own library
var newDirectory = applicationData / "NewDirectory";
newDirectory.CreateDirectory();

IFileSystem fileSystem = new FileSystem();
fileSystem.File.Create(newDirectory / "test.txt");

(newDirectory / "..").GetDirectories(fileSystem)

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, environment variables, and custom exit code handling
await new SimpleExecRunner("git")
    .AddArguments("status", "--porcelain")
    .WithWorkingDirectory(repoRoot)
    .WithConfigureEnvironment(env => env["GIT_TERMINAL_PROMPT"] = "0")
    .WithExitCodeHandler(code => code is 0 or 1)
    .RunAsync();

Key types:

  • SimpleExecRunner — the fluent builder. Create with new SimpleExecRunner("command-name"), add arguments, then call Run(), RunAsync(), or ReadAsync().
  • ISimpleExecCommandWrapper — an interface wrapping SimpleExec.Command to enable unit testing. The default implementation (SimpleExecCommand) delegates directly to the static Command class.

Template

You can use the FileBasedApp.Toolkit.Template to easily create a new filebase app with FileBasedApp.Toolkit references added https://www.nuget.org/packages/FileBasedApp.Toolkit.Template/

Bugs or things missing

Feel free to create an issue or submit a pull request.

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 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.  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. 
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:

Package Downloads
FileBasedApp.Toolkit.CSharp

Roslyn-based helpers for detecting and working with file-based .NET apps.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.17.0-rc-01 0 3/25/2026
0.16.0 110 3/15/2026
0.15.0 119 3/13/2026
0.15.0-rc-01 98 3/12/2026
0.15.0-dev-05 88 3/11/2026
0.15.0-dev-03 87 3/11/2026
0.15.0-dev-02 77 3/11/2026
0.15.0-dev-01 101 3/11/2026
0.14.0 112 3/10/2026
0.14.0-preview-02 84 3/10/2026
0.13.0 75 3/8/2026
0.12.0 75 3/7/2026
0.11.2 84 3/5/2026
0.11.1 73 3/5/2026
0.11.0 78 3/5/2026
0.10.3 84 3/2/2026
0.10.2 165 2/28/2026

- Added SimpleExecRunner: a fluent builder for constructing and executing system commands via SimpleExec (Run, RunAsync, ReadAsync)
- Added ISimpleExecCommandWrapper and SimpleExecCommand for testable wrapping of SimpleExec's static Command class
- Updated TruePath dependency to 1.12.0
     - Decoupled direct dependency on TruePath.TestableIO.System.IO (Now a package reference instead of project reference in code)