Hosted VS2017 Windows. But I suspect that this request is for every agent type.
VisualStudio.com
While creating the build definition manually, I have an option to set build number format using Option tab:

Currently, in YAML build definition, I'm not able to set that. Also after the build definition is created, I'm unable to manually set that option (Options tab is gone if I'm using YAML ).
My question is: is it possible to achieve this right now?
My understanding is that setting the following at the top of your yaml file achieves that:
name: $(Build.DefinitionName)-$(date:yyyyMMdd)$(rev:.r)
See https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-name.md
This then populates Build.BuildNumber
@simonvane yes that did the trick. thank you for your quick response!
@simonvane the link no longer works:(
the docs moved. This doc contains links to the new and old docs: https://github.com/Microsoft/azure-pipelines-agent/blob/master/docs/preview/yamlgettingstarted.md
Here was the old doc: https://github.com/Microsoft/azure-pipelines-agent/blob/3d39fca3cac2bf54c16600e0a3b9e7972d4c5ef3/docs/preview/yamlgettingstarted-name.md
@simonvane Thanks man! It really helped me!
Most helpful comment
My understanding is that setting the following at the top of your yaml file achieves that:
See https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-name.md
This then populates Build.BuildNumber