FileBasedApp.Toolkit.Spectre 1.4.0

dotnet add package FileBasedApp.Toolkit.Spectre --version 1.4.0
                    
NuGet\Install-Package FileBasedApp.Toolkit.Spectre -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.Spectre" 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.Spectre" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="FileBasedApp.Toolkit.Spectre" />
                    
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.Spectre --version 1.4.0
                    
#r "nuget: FileBasedApp.Toolkit.Spectre, 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.Spectre@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.Spectre&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=FileBasedApp.Toolkit.Spectre&version=1.4.0
                    
Install as a Cake Tool

FileBasedApp.Toolkit.Spectre

Optional Spectre.Console and Spectre.Console.Cli integration.

  • FileBasedApp.Toolkit.AnsiConsoleFactory creates stderr and quiet consoles.
  • FileBasedApp.Toolkit.CommandCli.ExtendedCommandSettings adds exception-based validation, path resolution, environment fallback and settings-file loading.

This package references FileBasedApp.Toolkit, Spectre.Console and Spectre.Console.Cli, but does not depend on SimpleExec. Deserializers and FlexibleFilePath remain in core.

Migration (1.4.0-preview-01)

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

<PackageReference Include="FileBasedApp.Toolkit.Spectre" 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 Spectre.Console or Spectre.Console.Cli.

Batch path validation

All protected TryGetFile, TryGetFiles, TryGetDirectory, and TryGetDirectories overloads remain available for backward compatibility. They now forward to the public static helpers on PathUtil in the core package, preserving their signatures and caller-argument expressions. Existing subclass calls need no changes. For use outside command settings, call PathUtil directly without adding a Spectre dependency; see the core path-validation examples.

Inside an ExtendedCommandSettings subclass, use TryGetFiles and TryGetDirectories to resolve arrays of candidate paths. Both return AbsolutePath[] and support .NET 10 and .NET 11. Overloads accept predefined roots, single absolute roots, or multiple roots through the existing params overload.

// Inside DoValidate():
AbsolutePath[] files = TryGetFiles(
    ["settings.json", "defaults.json"], shouldExist: true,
    root: PredefinedRootPath.CurrentDirectory);

AbsolutePath[] directories = TryGetDirectories(
    ["input", "output"], allowEmpty: false, shouldExist: true,
    root: PathUtil.GetCurrentWorkingFolder());

Null candidate arrays are rejected. TryGetFiles also rejects an empty array. TryGetDirectories treats an empty array as a single empty candidate: allowEmpty controls whether it can resolve to a root directory. For multiple candidates, validation errors are collected into one InvalidOperationException; the base Validate() method converts the exception message into a validation error.

Extended settings

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

using FileBasedApp.Toolkit;
using FileBasedApp.Toolkit.CommandCli;
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();
    }
}
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 79 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.