I have a release pipeline and want to add a stage with a task that will write a version number into a file that is stored in TFVC.
I have been attempting to use a powershell task that calls tf.exe to work with files. I thought I'd start just by trying to download the file before considering attempting to check it back in. I can't seem to authorize using tf.exe to download a file. Can you help?
$workspaceName = "temp_123"
$login = "/login:.,$env:SYSTEM_ACCESSTOKEN"
& tf vc workspace /new /noprompt $workspaceName /collection:https://mycorp.visualstudio.com $login
Try
{
& tf vc workfold /unmap "$/" /workspace:$workspaceName $login
& tf vc workfold /map "$/SomePath" $dir /workspace:$workspaceName $login
& tf vc get $login
}
Finally
{
& tf vc workspace /delete $workspaceName /collection:https://mycorp.visualstudio.com $login
}
# Verify it appeared
if (-Not (Test-Path "$dir\Version.txt")) { throw "failed to download" }
I get this error:
TF30063: You are not authorized to access https://mycorp.visualstudio.com/
How do you authenticate with tf.exe when you have a system access token? Or is there a better way to download and checkin files.