YosriMlik.FileWatcher 1.0.2

dotnet tool install --global YosriMlik.FileWatcher --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local YosriMlik.FileWatcher --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=YosriMlik.FileWatcher&version=1.0.2
                    
nuke :add-package YosriMlik.FileWatcher --version 1.0.2
                    

🔍 .NET File Watcher Tool

A powerful, colorful file watcher tool for .NET developers that monitors file changes and automatically rebuilds/restarts your application with beautiful console output.

NuGet License: MIT

✨ Features

Customizable Build & Run Commands - Define your own build and run commands
File Filtering - Include/exclude files using powerful glob patterns
Auto Kill & Restart - Automatically kills and restarts your app on changes
Debouncing - Configurable debounce to avoid rapid rebuilds
Cross-Platform - Works on Windows, Linux, and macOS
.NET 8+ Compatible - Built for .NET 8 and works with newer versions
Colorful Console Output - Beautiful, emoji-rich colored terminal output
No Shell Wrapper - Direct process execution preserves all colors and emojis

📦 Installation

dotnet tool install --global DotNet.FileWatcher

Update to Latest Version

dotnet tool update --global DotNet.FileWatcher

Install from Source

git clone https://github.com/YourUsername/FileWatcher.git
cd FileWatcher
dotnet pack -c Release
dotnet tool install --global --add-source ./bin/Release DotNet.FileWatcher

Verify Installation

dotnet-file-watcher --help

🚀 Quick Start

1. Initialize Configuration

Navigate to your project directory and create a configuration file:

cd YourProject
dotnet-file-watcher init

This creates a filewatcher.json file with default settings:

{
  "BuildCommand": "dotnet build",
  "RunCommand": "dotnet run",
  "IncludedFiles": [
    "**/*.cs",
    "**/*.csproj",
    "**/*.json",
    "**/*.razor",
    "**/*.cshtml"
  ],
  "ExcludedFiles": [
    "**/bin/**",
    "**/obj/**",
    "**/.git/**",
    "**/.vs/**",
    "**/node_modules/**"
  ],
  "DebounceMilliseconds": 500,
  "KillOnChange": true,
  "WorkingDirectory": "."
}

2. Customize Configuration

Edit filewatcher.json to match your needs:

Example for ASP.NET Core:

{
  "BuildCommand": "dotnet build",
  "RunCommand": "dotnet run --urls=https://localhost:5001",
  "IncludedFiles": ["**/*.cs", "**/*.cshtml", "**/*.razor", "**/*.css"],
  "ExcludedFiles": ["**/bin/**", "**/obj/**"],
  "DebounceMilliseconds": 300,
  "KillOnChange": true,
  "WorkingDirectory": "."
}

Example for Custom Scripts:

{
  "BuildCommand": "npm run build",
  "RunCommand": "node dist/server.js",
  "IncludedFiles": ["**/*.ts", "**/*.js"],
  "ExcludedFiles": ["**/node_modules/**", "**/dist/**"],
  "DebounceMilliseconds": 1000,
  "KillOnChange": true,
  "WorkingDirectory": "."
}

3. Start Watching

dotnet-file-watcher

The tool will:

  1. Run the initial build command
  2. Start your application
  3. Watch for file changes
  4. Kill the current process and rebuild/restart on changes

4. Stop Watching

Press Ctrl+C to stop the watcher.

⚙️ Configuration Options

Option Type Description Default
BuildCommand string Command to build the project "dotnet build"
RunCommand string Command to run the application "dotnet run"
IncludedFiles array Glob patterns for files to watch ["**/*.cs", "**/*.csproj", ...]
ExcludedFiles array Glob patterns for files to ignore ["**/bin/**", "**/obj/**", ...]
DebounceMilliseconds number Wait time before rebuilding after change 500
KillOnChange boolean Kill running process before rebuild true
WorkingDirectory string Directory to watch and execute commands in "."

Glob Pattern Examples

  • **/*.cs - All C# files in all directories
  • *.json - JSON files in root directory only
  • src/**/*.cs - All C# files under src directory
  • !**/bin/** - Exclude bin directories (use in ExcludedFiles)

🎯 Use Cases

ASP.NET Core Development

Watch for changes in controllers, views, and models:

{
  "BuildCommand": "dotnet build",
  "RunCommand": "dotnet run",
  "IncludedFiles": ["**/*.cs", "**/*.cshtml", "**/*.razor"]
}

Blazor Development

{
  "BuildCommand": "dotnet build",
  "RunCommand": "dotnet run",
  "IncludedFiles": ["**/*.cs", "**/*.razor", "**/*.css"]
}

Worker Service

{
  "BuildCommand": "dotnet build",
  "RunCommand": "dotnet run",
  "IncludedFiles": ["**/*.cs", "**/*.json"],
  "DebounceMilliseconds": 1000
}

💡 Tips

  • Set a higher DebounceMilliseconds value if you're making rapid changes
  • Use specific include patterns to reduce unnecessary rebuilds
  • Set KillOnChange: false if you want to manually manage processes
  • You can omit BuildCommand if you only need to restart without rebuilding
  • Use relative paths in WorkingDirectory or absolute paths

🗑️ Uninstall

dotnet tool uninstall --global DotNet.FileWatcher

🛠️ Building from Source

git clone https://github.com/YourUsername/FileWatcher.git
cd FileWatcher
dotnet build
dotnet pack -c Release
dotnet tool install --global --add-source ./bin/Release DotNet.FileWatcher

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built with ❤️ for the .NET community
  • Inspired by the need for a better file watching experience
  • Thanks to all contributors!

📧 Support

If you encounter any issues or have questions:

🌟 Star History

If you find this tool useful, please consider giving it a ⭐ on GitHub!

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 was computed.  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.

This package has no dependencies.

Version Downloads Last Updated
1.0.2 121 12/13/2025
1.0.1 120 12/13/2025