I am using the new scripting capabilities in Visual Studio Online (rather than the XAML assembly definition), and I am trying to ensure that the build version number includes the latest Git Commit ID of the target repository using the build number format.
I use the following assembly number format:
$(MajorVersion).$(MinorVersion).$(BuildId).$(SourceVersion)
The result is the generated version number 1.0.1234. - that is, the value of SourceVersion is empty, which causes an error in VSO when the build order is. I also tried to qualify a variable by prefixing it with Build. with the same result. To check, I changed the build number in the following format:
$(MajorVersion).$(MinorVersion).$(BuildId).$(SourceBranch)
This correctly results in a value of 1.0.1234.refs_heads_master
I used Predefined Variables and Build.SourceVersion are listed as a global variable.
Am I doing something wrong, am I facing an error or is it by design and unavailable at the time of assembling the assembly in the queue? If this is by design, is there a way to automatically include a short Git Commit ID in assembly number format?
Here I set the build number format in VSO: 
This is the error that I see when I do not explicitly specify Git CommitId:
400: Build number format string $ (MajorVersion). $ (MinorVersion). $ (BuildId). $ (SourceVersion) generated build number 0.1.1. which contains invalid character (s) is also long or ends with ".". The maximum length of the build number is 255 characters. Characters that are not allowed include "," / ",": ", '<', '>', '\', '|', '?', '@' And '*'.
git vsts vsts-build
Garyjl
source share