My build pipeline gets sources in the local sources folder via "Get sources". I would like to get some other files from a different project.
Conditions
- Azure DevOps Server on Premise
- Self hosted build agent
- TFVC (not git)
- There is an existing mapping in ..\w\XXX\s\ to $projectA\subdir\branch
- I want to get files from another project $projectB\subdir\branch
- $projectB is not mapped
- Only Powershell and tf.exe - I know the extra mapping function in the pipeline UI, but I would like to script that
I tried:
$collection = "well my collection..."
$tfsProjectTargetPath = "`$/projectB/subdir/branch"
$localWorkDir = $env:SYSTEM_DEFAULTWORKINGDIRECTORY
$workspaceName = $env:Build_Repository_Tfvc_Workspace
& $tf vc workfold /map /workspace:$workspaceName $localWorkDir /collection:$collection /noprompt
That runs into "TF14061: The workspace ws_XXX_YYYY;user does not exist.".
I also tried creating a new workspace:
$workspaceName = "some new name"
& $tf vc workspace /new /location:local /permission:Public $workspaceName /collection:$collection /noprompt
That runs into "The path ..\w\220\s\projectA\subidr\branch is already mapped in workspace ws_XXX_YYYY;Build\<guid>".
To me it seems the value of $workspaceName + user is the issue. Somehow the $workspaceName is coupled to a "build:" user. My powershell runs with a different user than the workspace.
Any suggestions or ideas?
I found the solution:
<workspacename>;Build\<collectionId>In Powershell, getting files from another project can be achieved with:
Now you can create a new workspace and a new mapping, like I mentioned in my question: