After a successful build, having configured the Label Format as $(GitVersion.NuGetVersion)
, the resulting tag is set to $(GitVersion.NuGetVersion)
not the actual expanded value of that variable.
In the build output logging, there are 2 sections/plans: Build, and Finalize Build.
Presumably, all the variable context/state is being lost once the build agent moves to the second section/plan.
How am I supposed to tag the source with the resulting GitVersion if the context of the GitVersion variables are lost during the Finalize Build section?
Specific steps to achieve my desired result:
https://www.visualstudio.com/en-us/docs/build/scripts/git-commands#enable-scripts-to-run-git-commands
https://git-scm.com/book/en/v2/Git-Basics-Tagging
I added 2 Command Line Tasks (a Batch Task would be a better idea) with Tool:
git
:tag -a $(GitVersion_NuGetVersion) -m "Auto-Tagged v$(GitVersion_NuGetVersion) by Build ($(Build.BuildId))"
push origin $(Build.BuildNumber)
I answered your question in the issue on GitHub: