I can get the build number from IBuildDetail.BuildNumber but this is taken from the build definition and there fore might not include the revision number $(Rev:.r) or it might not be at the end.
So I would like to get this number without having to parse it from the build number. Is this property available any where during the build?
Use the build variables.
From PowerShell use $Env:BUILD_BUILDNUMBER
if you’re using TFS 2015.
See MSDN: Use a PowerShell script to customize your build process
For previous versions: Team Foundation Build environment variables
you can use following powershell script to parse Build number
[String]$myrev = $Env:BUILD_BUILDNUMBER
$result = $myrev.Substring($myrev.LastIndexOf('.') + 1)
Write-Host $result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With