How File Watching Works
The file watcher uses VS Code’s built-in file system watching capabilities to monitor changes:File watching is automatically enabled when the extension activates. No manual setup required!
Watched Files
The file watcher monitors two categories of files:1. Source Files
By default, watches all .NET source code files:- C# files -
**/*.cs - F# files -
**/*.fs - VB.NET files -
**/*.vb
2. Project Files
Also monitors .NET project and solution files:- C# projects -
**/*.csproj - F# projects -
**/*.fsproj - VB.NET projects -
**/*.vbproj - Solution files -
**/*.sln
Monitored Events
The file watcher responds to three types of file system events:File Created
New source files are automatically added to the appropriate project.
File Changed
Modified files trigger NuGet compatibility checks.
File Deleted
Removed files are automatically excluded from project files.
Excluded Directories
To avoid watching build artifacts and dependencies, certain directories are excluded by default:**/bin/**- Build output directories**/obj/**- Intermediate compilation files**/node_modules/**- Node.js dependencies (if present)
These exclusions prevent unnecessary updates from generated files and keep the watcher focused on your actual source code.
Debouncing
To prevent excessive updates when multiple files change rapidly, the file watcher uses debouncing:How Debouncing Works
Automatic Update Flow
When a file change is detected, Build Buddy executes the following sequence:Configuration Options
Enable/Disable Auto-Update
You can control whether automatic updates occur:settings.json
Enable or disable automatic updates when files change. When disabled, you must use manual commands to update project files.
Customize Watch Patterns
settings.json
Glob patterns for files to watch. Add or remove patterns based on your project needs.
Customize Exclusions
settings.json
Glob patterns for directories to exclude from watching. Files in these directories won’t trigger updates.
Logging and Debugging
The file watcher provides detailed console logging for debugging:View file watcher logs
View file watcher logs
To see detailed file watcher logs:
- Open the Developer Console:
Help > Toggle Developer Tools - Switch to the Console tab
- Filter for “DotNET Build Buddy” messages
- Monitor real-time file change events and update operations
Performance Considerations
Large Workspaces
For workspaces with thousands of files:Optimized: VS Code’s file watchers are highly efficient and use native OS file system events
Debouncing: The 1-second delay prevents excessive updates during bulk operations
Selective watching: Only monitors .NET-related files, not every file in your workspace
Resource Usage
- The extension is deactivated
- VS Code is closed
- The workspace is changed
Common Scenarios
Scenario 1: Adding New Files
Scenario 2: Bulk File Operations
Scenario 3: Git Branch Switch
Integration with Other Features
The file watcher triggers multiple Build Buddy features:NuGet Compatibility Checks
Every automatic update includes compatibility verification:Solution Regeneration
Manual Override
Even with auto-update disabled, you can trigger updates manually:Troubleshooting
Files not being detected
Files not being detected
Symptoms: Changes to source files don’t trigger updatesSolutions:
- Check that
autoUpdateis enabled in settings - Verify files aren’t in excluded directories (
bin/,obj/) - Check watch patterns match your file extensions
- Look for errors in the Developer Console
Too many updates
Too many updates
Symptoms: Projects update too frequently, causing performance issuesSolutions:
- The debounce timer should prevent this, but if you experience it:
- Disable auto-update and use manual commands
- Check if other extensions are modifying files
- Add problematic directories to
excludePatterns
Updates not completing
Updates not completing
Symptoms: File changes detected but projects don’t updateSolutions:
- Check Developer Console for error messages
- Verify write permissions on project files
- Try manual update command to see specific errors
- Ensure project files aren’t locked by another process
Excluded files still triggering updates
Excluded files still triggering updates
Symptoms: Files in
bin/ or obj/ cause updatesSolutions:- Verify
excludePatternssyntax in settings - Ensure patterns use glob format (
**/bin/**) - Check that patterns cover your actual directory structure
- Use absolute paths for debugging in console logs
Best Practices
Keep auto-update enabled
Auto-update provides the best developer experience, keeping your project files always in sync.
Trust the debouncing
The 1-second delay is optimized. Don’t worry about rapid file changes.
Exclude build artifacts
Always exclude
bin/, obj/, and package directories for best performance.Check the console
When debugging issues, the Developer Console shows exactly what the watcher is doing.
Related Topics
- Project Management - What happens when updates are triggered
- NuGet Compatibility - Automatic checks during file updates