YosriMlik.FileWatcher
1.0.2
dotnet tool install --global YosriMlik.FileWatcher --version 1.0.2
dotnet new tool-manifest
dotnet tool install --local YosriMlik.FileWatcher --version 1.0.2
#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.
✨ 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
Install from NuGet (Recommended)
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:
- Run the initial build command
- Start your application
- Watch for file changes
- 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 onlysrc/**/*.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
DebounceMillisecondsvalue if you're making rapid changes - Use specific include patterns to reduce unnecessary rebuilds
- Set
KillOnChange: falseif you want to manually manage processes - You can omit
BuildCommandif you only need to restart without rebuilding - Use relative paths in
WorkingDirectoryor 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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:
- Open an issue on GitHub
- Check out the Quick Start Guide
- Read the Complete Code Explanation
🌟 Star History
If you find this tool useful, please consider giving it a ⭐ on GitHub!
| Product | Versions 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. |
This package has no dependencies.