TFS 2015.2远程执行脚本删构建报错:未找到符合条件的构建
tfsbuild delete/destroy in TFS 2015.2 Let's break down the most common reasons you're hitting this error (even when you know matching builds exist) and walk through actionable fixes:
1. Double-check your build specification parameters
TFS is strict about exact matches for project names, build definitions, and collection URLs—small typos or case mismatches can easily cause the command to return zero results.
- Always specify the full collection URL: Omitting the
/collectionparameter might default to a different collection than you expect. Example:tfsbuild delete /collection:http://your-tfs-server:8080/tfs/DefaultCollection /teamproject:"Your Team Project Name" - Wrap spaced names in quotes: If your team project or build definition has spaces, enclose them in double quotes to avoid parsing errors.
- Confirm build definition names: Use the exact name from the TFS web UI (under Builds) — don't rely on a shortened or display-only name.
2. Expand your filter criteria to include all target builds
By default, tfsbuild delete might only target builds in specific states or date ranges. If your unprotected builds fall outside these defaults, they won't be picked up.
- Include all build states: Add
/status:Allto ensure you're not excluding failed, partially succeeded, or stopped builds. Example:tfsbuild delete /collection:http://your-tfs-server:8080/tfs/DefaultCollection /teamproject:"Your Team Project" /builddefinition:"Your Build Def" /status:All - Set a broad date range: Explicitly define a range that covers all builds you want to remove using the format
YYYY-MM-DD~YYYY-MM-DD:tfsbuild delete /collection:http://your-tfs-server:8080/tfs/DefaultCollection /teamproject:"Your Team Project" /builddefinition:"Your Build Def" /dateRange:"2015-01-01~2024-01-01" /status:All
3. Verify your account's permissions
TFS doesn't always flag permission issues directly—instead, it might return "No builds found" if your account lacks required rights.
- Required permissions: Ensure your account has the Delete builds permission (for
tfsbuild delete) or Destroy builds permission (fortfsbuild destroy) enabled at the team project level. - How to check:
- Open the TFS web UI, navigate to your team project.
- Click the gear icon (Settings) → Security.
- Locate your account in the list, then check the "Builds" section. Make sure "Delete builds" is set to Allow.
4. Test with tfsbuild list first
Before deleting, use the tfsbuild list command with identical parameters to confirm you can see the builds you want to remove. This isolates whether the issue is with the delete command itself or your specification.
Example list command:
tfsbuild list /collection:http://your-tfs-server:8080/tfs/DefaultCollection /teamproject:"Your Team Project" /builddefinition:"Your Build Def" /status:All /dateRange:"2015-01-01~2024-01-01"
If this returns the expected builds, simply replace list with delete (or destroy) and add /noprompt to skip confirmation prompts.
5. Understand the difference between delete and destroy
tfsbuild deletemarks builds as deleted but keeps them in the database (they can be restored later).tfsbuild destroypermanently removes builds from the database and requires the higher-level Destroy builds permission.
Make sure you're using the right command for your needs and have the corresponding permissions.
6. Check for TFS 2015.2-specific bugs
TFS 2015.2 has a few known quirks around build retention and filtering. If none of the above fixes work, applying the latest cumulative update for TFS 2015.2 can resolve issues with build matching logic.
内容的提问来源于stack exchange,提问作者chandu

