Skip to main content
DotNET Build Buddy uses file system watchers to monitor changes in your workspace and automatically update project files. This page explains how to configure watch patterns effectively.

Overview

The extension monitors two types of files:
  1. Source files - Files specified in watchPatterns (e.g., .cs, .fs, .vb)
  2. Project files - Automatically monitored (.csproj, .fsproj, .vbproj, .sln)
When changes are detected, the extension triggers an automatic update after a 1-second debounce period.

Watch Patterns

Default Configuration

By default, the extension watches for common .NET source files:
{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.fs",
    "**/*.vb"
  ]
}

Pattern Syntax

Watch patterns use glob syntax:
  • ** - Matches any number of directories
  • * - Matches any characters in a filename
  • ? - Matches a single character
  • {a,b} - Matches either pattern a or b

Common Patterns

C# Projects

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.xaml",
    "**/*.resx"
  ]
}

F# Projects

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.fs",
    "**/*.fsx",
    "**/*.fsi"
  ]
}

Multi-Language Solutions

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.fs",
    "**/*.vb",
    "**/*.xaml",
    "**/*.razor"
  ]
}

Blazor Projects

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.razor",
    "**/*.cshtml"
  ]
}

Exclude Patterns

Default Configuration

The extension excludes common build artifacts and dependencies:
{
  "dotnetBuildBuddy.excludePatterns": [
    "**/bin/**",
    "**/obj/**",
    "**/node_modules/**"
  ]
}

Why Exclude Patterns Matter

Exclude patterns prevent the extension from:
  • Watching build output directories
  • Creating infinite update loops
  • Monitoring temporary or generated files
  • Processing files that aren’t part of your source code
{
  "dotnetBuildBuddy.excludePatterns": [
    // Build outputs
    "**/bin/**",
    "**/obj/**",
    
    // Package directories
    "**/node_modules/**",
    "**/packages/**",
    
    // Version control
    "**/.git/**",
    "**/.svn/**",
    
    // IDE folders
    "**/.vs/**",
    "**/.vscode/**",
    "**/.idea/**",
    
    // Temporary files
    "**/*.tmp",
    "**/*.temp"
  ]
}

How File Watching Works

File Change Detection

The extension monitors three types of events:
  1. File Created - New files added to the workspace
  2. File Changed - Existing files modified
  3. File Deleted - Files removed from the workspace
See fileWatcher.ts:41-43 for implementation details.

Debouncing

To prevent excessive updates, the extension uses a 1-second debounce timer. This means:
  • Multiple rapid changes trigger only one update
  • The update occurs 1 second after the last change
  • Better performance with batch file operations
See fileWatcher.ts:91-108 for debouncing logic.

Update Process

When a change is detected:
  1. Check if autoUpdate is enabled
  2. Verify the file doesn’t match exclusion patterns
  3. Start debounce timer
  4. After 1 second, update project files
  5. Regenerate solution file if needed

Pattern Matching Behavior

Case Sensitivity

Pattern matching is typically case-insensitive on Windows and case-sensitive on Linux/macOS:
// These are equivalent on Windows, different on Linux
{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.CS",  // Windows: matches .cs and .CS
    "**/*.cs"   // Linux: only matches .cs
  ]
}
Use lowercase extensions in patterns for cross-platform compatibility.

Exclusion Priority

Exclusion patterns take priority over watch patterns:
{
  "dotnetBuildBuddy.watchPatterns": ["**/*.cs"],
  "dotnetBuildBuddy.excludePatterns": ["**/bin/**"]
}
// Result: Watches all .cs files EXCEPT those in bin/ directories

Advanced Configuration

Watching Specific Directories

{
  "dotnetBuildBuddy.watchPatterns": [
    "src/**/*.cs",
    "lib/**/*.cs",
    "tests/**/*.cs"
  ]
}

Multiple File Types with Braces

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.{cs,fs,vb}",
    "**/*.{xaml,razor}"
  ]
}

Excluding Generated Code

{
  "dotnetBuildBuddy.excludePatterns": [
    "**/bin/**",
    "**/obj/**",
    "**/*.Designer.cs",
    "**/*.g.cs",
    "**/*.generated.cs"
  ]
}

Troubleshooting

Files Not Being Watched

Ensure your file extension is included in watchPatterns. The extension only watches files that match the configured patterns.
Check if the file’s path matches any excludePatterns. Exclusions take priority over watch patterns.
Ensure dotnetBuildBuddy.autoUpdate is set to true. When disabled, automatic updates won’t occur.
Make sure the file is within your VS Code workspace. Files outside the workspace aren’t monitored.

Too Many Updates

1

Review watch patterns

Ensure you’re not watching more files than necessary. Remove patterns for file types that don’t affect project structure.
2

Add exclusion patterns

Exclude directories with frequently changing files (logs, temp files, etc.).
3

Check for build loops

Verify that bin/ and obj/ directories are excluded to prevent update loops.

Performance Issues

If file watching causes performance problems:
{
  // Reduce watch scope
  "dotnetBuildBuddy.watchPatterns": [
    "src/**/*.cs"  // Only watch src/ directory
  ],
  
  // Exclude more aggressively
  "dotnetBuildBuddy.excludePatterns": [
    "**/bin/**",
    "**/obj/**",
    "**/node_modules/**",
    "**/packages/**",
    "**/.git/**",
    "**/logs/**"
  ]
}

Workspace vs User Settings

Workspace Settings

Configure per-project patterns in .vscode/settings.json:
{
  "dotnetBuildBuddy.watchPatterns": [
    "src/**/*.cs",
    "lib/**/*.cs"
  ]
}
Workspace settings override user settings and are ideal for project-specific configurations.

User Settings

Configure global defaults in User Settings:
{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.fs",
    "**/*.vb"
  ]
}

Examples by Project Type

ASP.NET Core Web Application

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.cshtml",
    "**/*.razor"
  ],
  "dotnetBuildBuddy.excludePatterns": [
    "**/bin/**",
    "**/obj/**",
    "**/wwwroot/lib/**",
    "**/node_modules/**"
  ]
}

Desktop WPF Application

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs",
    "**/*.xaml",
    "**/*.resx"
  ],
  "dotnetBuildBuddy.excludePatterns": [
    "**/bin/**",
    "**/obj/**",
    "**/*.Designer.cs"
  ]
}

Class Library

{
  "dotnetBuildBuddy.watchPatterns": [
    "**/*.cs"
  ],
  "dotnetBuildBuddy.excludePatterns": [
    "**/bin/**",
    "**/obj/**",
    "**/packages/**"
  ]
}

Next Steps

Settings Overview

View all configuration options

NuGet Settings

Configure NuGet compatibility checking

Build docs developers (and LLMs) love