You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在vNext Build中仅获取部分Shelveset?

TFVC Gated Check-In: Fixing UnShelve Failures for Unmapped Directories

Great question—this is a common pain point with TFVC gated check-ins when you're trying to scope builds to specific directories. Let's break down what's going on and the solutions you can use:

Core Issue

The default GetSources task in vNext Build doesn't expose a built-in setting to specify an itemSpec for partial unshelving, which is why you're hitting folder mapping errors when your shelveset includes changes in unmapped directories like Documents.

Workaround Solutions

1. Cloak the Unmapped Directory in Your Build Workspace

The simplest fix is to adjust your build definition's workspace mapping to cloak the Documents directory. This tells the GetSources task to ignore changes in that directory during unshelving, without needing to map it fully:

  • Open your build definition, go to the Repository tab
  • Under Workspace, click Edit
  • Add a new mapping for $/YourProject/Documents and set the Type to Cloak
  • Save the definition, and future gated builds will skip unshelving changes in the cloaked directory

2. Replace Default GetSources with a Custom tf unshelve Script

If you need full control over what gets unshelved, disable the default GetSources task and use a custom script (PowerShell or Command Line) to run the tf unshelve command with your desired itemSpec:

  1. In your build definition, go to the Get sources section and disable the task (uncheck the box next to it)
  2. Add a Command Line task with the following command (adjust paths to match your TFVC project):
    tf unshelve /s:http://your-tfs-server:8080/tfs/YourCollection "$(Build.SourcesShelvesetName)" /itemSpec:"$/YourProject/Sources/*" /recursive
    
  3. Optional: Add a prior task to initialize the build workspace if needed (use tf workspace and tf get commands to set up the base workspace before unshelving)

3. Restrict Gated Check-In Triggers to Only the Sources Directory

Another approach is to limit which changes trigger your gated build definition, so changes to Documents never hit this build in the first place:

  • Go to your Team Project's Settings > Version Control > Check-in Policies
  • Edit the Gated Check-in policy, select your build definition
  • Click Filter paths and add an include rule for $/YourProject/Sources/*, then exclude any other paths you don't want to trigger the build
  • Save the policy—now only changes in the Sources directory will trigger this gated build, avoiding the unmapped directory issue entirely

Key Note

As of the latest vNext Build versions, there's still no native UI setting in the GetSources task to specify an itemSpec for partial unshelving. The workarounds above are the recommended ways to handle this scenario.

内容的提问来源于stack exchange,提问作者huserben

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:13:18