Build Versioning
This extension provides a build task to calculate or aquire the build version and to apply the version on several artifacts. Please add this task at the beginning of your build definition.
Quick steps to get started
- Define the version source and main versioning patterns in the general section.
- Choose the version source
- Build Number - Get the version from the current build number (by using macros).
- Variable - Use a dedicated variable which contains the version information
- GitVersion - Run (and install) GitVersion and use the calculated version information
- More to come - Please provide your ideas and requirements at BuildVersioning Issues
- Define the assembly version pattern and build number format
2. Define how to apply the version information to artifacts. Currently supported:
- .NET Assembly Version
- Nuspec
- Npm
- .NET Core
- Android (Xamarin)
- iOS (Xamarin)
- More to come - Please provide your ideas and requirements at BuildVersioning Issues
- If you need to somehow access the version information later on, the following variables are created by this task:
- BuildVersion.MajorVersion
- BuildVersion.MinorVersion
- BuildVersion.PatchVersion
- BuildVersion.BuildCounter
- BuildVersion.Version
- BuildVersion.VersionInfo
- BuildVersion.SemVer
- BuildVersion.AssemblySemVer
Branch creation during execution of GitVersion
The VSTS / TFS build agent checks out the commit directly since the branch pointer can move between build queue time and build execution time. This is the reason why the Git repository on the build agent is in detached head state.
This implies some problems for GitVersion to determine the correct version. Additionally, during a pull request, the commit reference does not have enough information.
We decided to create branches during GitVersion execution which are pointing to the correct commit.
- During a build, we read the build information about the branch being built.
- We either move the branch pointer or create a new branch in this repository.
- During a Pull Request, we create a branche named like the feature branch you are trying to integrate.
- After GitVersion is run, we cleanup the branches.
- If the branch pointers have been moved, we move them back to their original commit.
- If the branch was created, we remove the branch.
Build Counter on fourth digit
If you like to have a build counter on the last digit you can activate the flag Overwrite the fourth digit with a build counter
and provide a build counter key. The build counter key is used to act as the identifier. As long as it stays the same, the corresponding counter value is incremented each build. Depending on the key chosen, the counter is used accross build definitions.
Example:
- If you would like to have a build counter for the Git repository as well as the major and minor version, you could define the following as key:
$(Build.Repository.Name)-$(BuildVersion.MajorVersion).$(BuildVersion.MinorVersion).$(BuildVersion.PatchVersion)
- This provides the functionality, that we have a counter value for the defined repository and the Major/Minor numbers.
- Build: RepoA 1.0.0 --> 1.0.0.1
- Build: RepoA 1.0.0 --> 1.0.0.2
- Build: RepoA 1.1.0 --> 1.1.0.1
Known issue(s)
- This extension is currently in preview (beta).
- Installer Url for GitVersion has to contain the version information in the ZIP file (i.e. GitVersion_4.0.0-beta0013.zip.)
Learn More
Please visit Build Versioning.
Minimum supported environments
- Minimum agent version: 2.123.0
Feedback