.tasksignore
The .tasksignore file allows you to control which files are excluded from task discovery in the Workspace Tasks extension.
Table of Contents
- Overview}
- How It Works
- File Format
- Examples
- Global Configuration
- Pattern Evaluation Order
- Best Practices
- Common Use Cases
- Troubleshooting
- Next Steps
This helps keep your task list focused on relevant tasks by filtering out unwanted files and directories.
Overview}
.tasksignore works similarly to .gitignore, using the same pattern syntax to specify which files and directories should be excluded from task scanning. When the extension searches for task files (like package.json, Makefile, build.gradle, etc.), it will skip any files that match patterns in .tasksignore files.
How It Works
- Per-Directory Control: Place a
.tasksignorefile in any directory to exclude files from that location and its subdirectories - Hierarchical Application: Ignore files are evaluated from the workspace root down to the file location
- Gitignore Syntax: Uses standard gitignore pattern matching rules
- Automatic Reload: Changes to
.tasksignorefiles are automatically detected and applied - Smart Defaults: The extension always ignores certain directories regardless of
.tasksignoresettings:**/node_modules/****/.git/****/.vscode-test/****/__pycache__/**
File Format
The .tasksignore file is a plain text file with one pattern per line. The format follows gitignore conventions:
Basic Rules
- One pattern per line: Each line specifies a pattern to exclude
- Comments: Lines starting with
#are treated as comments and ignored - Empty lines: Empty lines are ignored
- No quotes needed: Patterns are specified directly without quotes
Pattern Syntax
| Pattern | Description | Example |
|---|---|---|
filename | Matches the filename in any directory | package.json |
*.ext | Matches all files with the extension | *.test.js |
dir/ | Matches the directory and all its contents | build/ |
**/pattern | Matches in all directories recursively | **/test/** |
dir/*.ext | Matches files in specific directory | scripts/*.sh |
!pattern | Negates a previous pattern (re-includes) | !important.js |
Task-Level Filtering
You can also ignore specific tasks within a file using the @ symbol. This allows you to hide individual tasks from your task list without ignoring the entire file.
The syntax for task-level filtering is filepath@taskname, where:
filepathis a valid file pattern (it must point to a file, not a directory).@is the separator.tasknameis the exact name of the task to ignore.
How Negation Works with Task-Level Rules
You can use the negation operator (!) in combination with task-level and file-level rules to create powerful filters. When you negate a task (!filepath@taskname), you ensure that specific task is included, even if the file itself or all of its tasks would otherwise be ignored.
This works through a simple priority system:
- If a file is ignored, all of its tasks are ignored.
- If a specific task is negated (
!file@taskname), it explicitly overrides the broader ignore rules for that one task. - If you ignore all tasks using a wildcard (
file@*) and negate one (!file@taskname), only that specific task will be shown from that file.
Task-Level Rule Forms
| Rule Form | Description | Example |
|---|---|---|
file@task | Hides a specific task from a specific file. | package.json@test |
file@* | Hides all tasks from a specific file. | Makefile@* |
!file@task | Re-includes a specific task that was otherwise ignored by a broader rule. | !package.json@build |
*.ext@task | Hides a task with a specific name across all files matching the pattern. | *.json@clean |
Worked Examples
Example: Hiding a single task while keeping the rest visible To hide only the serve task from your package.json but keep build and test visible:
# Ignore only the "serve" task in package.json
package.json@serve
Example: Hiding all tasks from a file but re-including one specific task If you have a customized Makefile and you only want the deploy task to be discovered, you can ignore all tasks in the file and then explicitly negate (re-include) deploy:
# Hide all tasks in the Makefile
Makefile@*
# Re-include the "deploy" task
!Makefile@deploy
Examples
Basic Example
# Ignore test files
**/test/**
**/*.test.js
**/*.spec.ts
# Ignore build outputs
build/
dist/
out/
target/
# Ignore temporary files
*.tmp
*.bak
*.swp
# Ignore specific tools
tools/legacy/
scripts/deprecated/
Advanced Example
# Ignore all JavaScript files in the scripts directory
scripts/*.js
# But keep the important ones
!scripts/deploy.js
!scripts/release.js
# Ignore all test directories except integration tests
**/test/**
!**/test/integration/**
# Ignore generated files
**/*.generated.*
**/auto-generated/**
# Ignore vendor and third-party code
vendor/
third-party/
external/
# Ignore CI/CD configuration
.github/
.gitlab-ci.yml
.travis.yml
# Ignore documentation build files
docs/build/
*.md.bak
Project-Specific Examples
Node.js Project
# Ignore test and coverage
coverage/
.nyc_output/
**/*.test.js
**/*.spec.js
# Ignore build artifacts
dist/
lib/
.next/
.nuxt/
# Ignore example and demo files
examples/
demo/
Python Project
# Ignore test files
**/test_*.py
**/*_test.py
tests/
# Ignore build and distribution
build/
dist/
*.egg-info/
# Ignore virtual environments
venv/
.venv/
env/
# Ignore Jupyter notebooks
**/*.ipynb
Multi-Language Project
# Frontend
frontend/node_modules/
frontend/dist/
**/*.test.tsx
# Backend
backend/target/
backend/build/
**/*Test.java
# Infrastructure
infrastructure/terraform/.terraform/
infrastructure/temp/
# Documentation
docs/build/
Global Configuration
In addition to .tasksignore files, you can configure workspace-wide exclusions in your Visual Studio Code settings.json:
{
"workspaceTasks.exclude": [
"**/.git/**",
"**/vendor/**",
"**/third-party/**",
"**/__pycache__/**"
]
}
These patterns will be applied globally across the entire workspace, regardless of .tasksignore files.
Pattern Evaluation Order
The extension evaluates ignore patterns in the following order:
- Built-in defaults: Always-ignored patterns (node_modules, .git, etc.)
- Global configuration: Patterns from
workspaceTasks.excludesetting - Local .tasksignore files: Patterns from
.tasksignorefiles, evaluated from closest to the file up to the workspace root
If any pattern matches, the file is excluded from task discovery.
Best Practices
- Place
.tasksignoreat project root: For workspace-wide rules - Use specific
.tasksignorefiles: For directory-specific exclusions - Comment your patterns: Use
#comments to explain complex patterns - Start broad, then refine: Begin with general patterns, add specific ones as needed
- Test your patterns: Use the Workspace Tasks view to verify files are excluded correctly
- Use negation sparingly: The
!operator can make patterns hard to understand - Prefer global config for permanent exclusions: Use
workspaceTasks.excludefor workspace-level settings
Common Use Cases
Exclude Test Files
**/test/**
**/__tests__/**
**/*.test.*
**/*.spec.*
Exclude Build Artifacts
build/
dist/
out/
target/
bin/
obj/
*.o
*.pyc
Exclude Example/Demo Code
examples/
demo/
sample/
playground/
Exclude Generated Code
**/*.generated.*
**/generated/**
**/auto-generated/**
Troubleshooting
Files Still Showing Up
- Check if the pattern syntax is correct
- Verify the
.tasksignorefile is in the correct location - Remember that patterns are relative to the
.tasksignorefile location - Use
**for recursive matching across directories
Pattern Not Working
- Ensure there are no leading/trailing spaces in patterns
- Use forward slashes
/in patterns (even on Windows) - Check for typos in filenames or extensions
- Remember that directory patterns should end with
/
Need to Re-include Files
Use the ! negation operator, but remember it only works if a parent pattern excluded the file first:
# Exclude all JS files
*.js
# But include this one
!important.js