如何在TFS 2015中通过TFVC手动为生成定义选择源分支?
Got it, let's break down exactly how to add the PowerShell scripts from your Scripts folder to the existing build definition for SystemA in TFS 2015 using TFVC. Here's the step-by-step process:
Step 1: Open the Build Definition Editor
Navigate to your SystemA build definition in TFS 2015, then click the Edit button to open its configuration interface.
Step 2: Access Workspace Mappings
In the editor, switch to the Repository tab (this is where TFVC source control settings live). Look for the Workspace mappings section—this is where you manage which server paths get pulled into the build workspace.
Step 3: Add a New Mapping for the Scripts Folder
- Click the Add button to create a new mapping entry.
- In the Server Path column:
- You can either click the browse icon (the little folder button) to navigate to
$/ProjectA/Scriptsand select it, or manually type the full server path. - If your Scripts folder has a trunk/subfolder structure (like
$/ProjectA/Scripts/trunk), make sure to select the correct path that contains your PowerShell scripts.
- You can either click the browse icon (the little folder button) to navigate to
- In the Local Path column:
- Set this to
$(Build.SourcesDirectory)\Scripts(this is a standard TFS build variable pointing to the root folder where source code is downloaded). This ensures the Scripts folder is placed alongside your SystemA code in the build workspace, making it easy to reference later.
- Set this to
- Leave the Type set to Map (the default option—this tells TFS to pull the entire contents of the server path to the local path).
Step 4: Verify and Save
Double-check that your new mapping is listed alongside the existing ones for $/ProjectA/SystemA/trunk/src and $/ProjectA/SystemA/trunk/deploy. Then click Save to apply the changes.
Quick Notes
- Even though your build definition's source branch is set to
$/ProjectA/SystemA/trunk, TFS 2015 allows you to map additional server paths outside of this branch—this is exactly what we're doing with the Scripts folder. - When setting up your build steps to run the PowerShell scripts, use the local path you defined (e.g.,
$(Build.SourcesDirectory)\Scripts\YourScript.ps1) to reference the files correctly. - You can test the setup by triggering a new build and checking the build logs or workspace on the build server to confirm the Scripts folder was downloaded successfully.
内容的提问来源于stack exchange,提问作者Alexandre Fernandes Bartolomeu

