TFS 2015中已解决工作项能否阻止代码签入关联及后续变更?
Great questions! Let’s walk through practical solutions for both scenarios in your TFS 2015 and Visual Studio 2015 setup:
1. Blocking Code Check-ins Linked to 'Resolved' Work Items
Absolutely, you can enforce this using TFS’s built-in check-in policies. Here’s how to set it up step by step:
Create a targeted work item query:
Build a query that filters for work items not in theResolvedstate (adjust the state name to match your exact workflow terminology). For example, use the filterState <> Resolved. Save this query in a shared team location so everyone can access it.Configure the Work Items check-in policy:
Head to your team project settings → Source Control → Check-in Policies. Add the Work Items policy, then set it to require that all linked work items match your custom query.Validate the policy:
From now on, anyone trying to check in code linked to aResolvedwork item will get a block from TFS, forcing them to use an active (non-Resolved) work item instead.
Pro tip: Keep the query updated if you ever modify your work item state names, and double-check that all team members have access to the query file.
2. Locking Work Items After QA Approval
To prevent changes once a work item gets QA sign-off, you’ll need to customize your work item type (WIT) definition and tweak permissions. Here are two reliable approaches:
Option 1: State Transitions + Read-Only Field Rules
- Add a "QA Approved" final state:
If your workflow doesn’t already include one, use the Process Editor (part of the TFS 2015 Power Tools for Visual Studio 2015) to add aQA Approvedstate to your WIT. - Set read-only rules:
In the WIT definition, add a rule that triggers when the work item transitions toQA Approved: mark all editable fields (like Description, Assigned To, or custom fields) as read-only. This ensures no one can modify the work item after approval.
Option 2: Permission-Based Locking
- Restrict edit access for the approved state:
Go to your team project’s security settings, navigate to the relevant work item node (or specific WIT type), and adjust permissions for user groups (e.g., Developers):- Deny the
Edit work items in this nodepermission specifically for work items in theQA Approvedstate. - Leave QA/Admin groups with edit access if you need to allow rare, controlled exceptions.
- Deny the
Either method will ensure that once a work item is QA-approved, it stays untouched unless explicitly allowed.
内容的提问来源于stack exchange,提问作者Anuj

