TeamCity allows me to report back from my MsBuild script using the ##teamcity interaction. I can use this to tell TeamCity that the build has FAILED, or ind
You can use the undocumented http request which has changed since it was originally posted. You now need "operationKind=1". I used a powershell runner like so:
$buildId = %teamcity.build.id%
$uri = "http://teamcity/ajax.html?guest=1&comment=Cancelling+build+for+some+reason&submit=Stop&buildId=$buildId&kill&operationKind=1"
$response = Invoke-WebRequest -UseBasicParsing -Uri $uri
Another SO post can tell you how to make an http request from MSBuild
The "guest=1" means I'm using the guest account, which at minimum needs the "Stop build / remove from queue" for the project you're going to cancel.