FsHotWatch.FileCommand 0.7.0-alpha.8

This is a prerelease version of FsHotWatch.FileCommand.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FsHotWatch.FileCommand --version 0.7.0-alpha.8
                    
NuGet\Install-Package FsHotWatch.FileCommand -Version 0.7.0-alpha.8
                    
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="FsHotWatch.FileCommand" Version="0.7.0-alpha.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FsHotWatch.FileCommand" Version="0.7.0-alpha.8" />
                    
Directory.Packages.props
<PackageReference Include="FsHotWatch.FileCommand" />
                    
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 FsHotWatch.FileCommand --version 0.7.0-alpha.8
                    
#r "nuget: FsHotWatch.FileCommand, 0.7.0-alpha.8"
                    
#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 FsHotWatch.FileCommand@0.7.0-alpha.8
                    
#: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=FsHotWatch.FileCommand&version=0.7.0-alpha.8&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FsHotWatch.FileCommand&version=0.7.0-alpha.8&prerelease
                    
Install as a Cake Tool

FsHotWatch.FileCommand

Plugin that runs a custom command when files matching a pattern change. Register multiple instances for different file patterns.

Why

Sometimes you want to run a specific command when certain files change -- type-check your .fsx scripts, validate SQL migrations, regenerate code from .proto files, etc. FileCommand lets you do this without writing a full plugin.

How it works

  1. You save a file
  2. FileCommandPlugin checks if the file matches its pattern
  3. If it matches, it runs the configured command
  4. Success/failure is reported to the error ledger

Configuration

In .fs-hot-watch.json:

{
  "fileCommands": [
    {
      "pattern": "*.fsx",
      "command": "dotnet",
      "args": "fsi --typecheck-only"
    },
    {
      "pattern": "*.sql",
      "command": "sqlfluff",
      "args": "lint"
    }
  ]
}
Field Type Default Description
name string derived from pattern Plugin identifier. Required when afterTests is set.
pattern string File pattern to match. *.ext matches any path ending with .ext. A literal filename (e.g. coverage-ratchet.json) matches only files with that exact basename.
afterTests true or string[] Fire after a test run completes. true fires on any completed run; an array fires only when all named projects complete. Requires name.
command string "echo" Command to run when triggered.
args string "" Arguments to the command.

At least one of pattern or afterTests must be specified. Both can be set on the same entry — e.g. a coverage ratchet that should re-run whenever tests complete OR when its config file changes:

{
  "fileCommands": [
    {
      "name": "coverage-ratchet",
      "pattern": "coverage-ratchet.json",
      "afterTests": true,
      "command": "dotnet",
      "args": "tool run coverageratchet"
    }
  ]
}

When pattern targets a non-source file (e.g. *.ratchet.json or coverage-ratchet.json), the daemon automatically extends its file watcher to cover that pattern so real edits trigger the plugin.

Environment variables on afterTests commands

The following environment variables are set on every afterTests command:

  • FSHW_RAN_FULL_SUITE: "true" if every project in the test run executed without an impact filter (i.e., the entire test suite ran), "false" if at least one project was filtered to a subset. Use this to gate baseline refreshes or threshold tightening — partial runs should not lower a coverage baseline or tighten a ratchet.

CLI

# Force a plugin to re-run, clearing its cached state
fs-hot-watch rerun coverage-ratchet

# Query a plugin's last-run status
fs-hot-watch coverage-ratchet-status

Programmatic usage

open FsHotWatch.PluginFramework
open FsHotWatch.FileCommand.FileCommandPlugin

// Type-check .fsx scripts when they change
let trigger: CommandTrigger =
    { FilePattern = Some(fun f -> f.EndsWith(".fsx"))
      AfterTests = None }

daemon.RegisterHandler(
    create
        (PluginName.create "scripts")       // plugin name
        trigger                             // CommandTrigger (pattern and/or afterTests)
        "dotnet"                            // command
        "fsi --typecheck-only build.fsx"    // args
        None                                // getCommitId for caching
)

For the combined trigger case (fires on file changes AND test completion):

let trigger: CommandTrigger =
    { FilePattern = Some(fun f -> f.EndsWith(".ratchet.json"))
      AfterTests = Some AnyTest }

See the FullPipelineExample for a complete setup.

Install

dotnet add package FsHotWatch.FileCommand
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. 
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
0.7.0-alpha.9 50 4/29/2026
0.7.0-alpha.8 55 4/25/2026
0.7.0-alpha.7 55 4/23/2026
0.7.0-alpha.3 56 4/18/2026
0.7.0-alpha.2 55 4/15/2026
0.6.0-alpha.1 54 4/12/2026
0.5.0-alpha.1 52 4/12/2026
0.3.0-alpha.1 61 4/8/2026
0.1.0-alpha.1 62 4/3/2026