I have a TFS2017 build and the first step is to check if a required folder exists on the c:\ drive. That folder is a pre-requisite for the build to finish properly so if the folder doesn't exist I want to display an error message and kill the build. I've tried returning -1 but that doesn't stop the build from continuing. Is there any way to kill a running build programmatically?
Here's my current PS script that checks for the folder. I've substituted xxxx for my actual folder names (to protect the innocent ;-):
param([string]$DirSuffix="x")
<#
This script is called by the xxxx build to make sure that the GVB folder
exists on c:\ before the build is run. It should be called by passing in the
directory suffix (e.g. \xxxx 2.3.1). I can't figure out how to
kill the build
if the folder doesn't exist so I'm just going to write multiple errors to
the console and hope that the builder see them and cancels the build.
#>
[string] $WholeDirectory='C:\XXXX' + $DirSuffix
if (-NOT [IO.Directory]::Exists($WholeDirectory))
{
Write-Host Directory $WholeDirectory does not exist - please make sure that the xxxx build has run first!!!
Write-Host "##vso[task.logissue type=error;] Directory $WholeDirectory does not exist - please make sure that the xxxx build has run
return -1
}