InCycle Software's Application Modernization and DevOps Blog

vNext Build Awesomeness – Managing Version Numbers

Written by Dave Burnison | Jun 18, 2015 7:52:58 PM

I have only been playing around with the vNext build system for a little while but, I have stumbled upon some real awesomeness! I now have a build template that allows me to create a new build definition, set a couple of variables, build and then my version numbers will automatically get updated AND I can connect those version numbers directly to the build number because they are using shared data.

In the screen shot below you can see that we have a single build that creates two .EXEs, they each have the same version number and that version number appears in the build number to makes it drop dead easy to determine when the EXE/DLL that I am testing was built:

 

This also makes it much easier to set the Found in Build and Integrated in Build fields on a bug. All I have to do is get the version number from the appropriate file's properties and enter that in the Found in Build or Integrated in Build field on the bug, (hopefully the version number also appears in an "About" dialog or page). I can use that information to find the offending build.


 

Ok, so how did I do this? Here are the simple steps:

  • Get the ApplyVersionToAssemblies.ps1 script from the Use a script to customize your build process MSDN documentation and save it to your work space. In my case I saved it to a BuildUtilities folder.
  • Add this to source control.
  • Create a new build.
  • Add a build step to call this new script
    • Press the Add Build Step… button/link
    • Select the PowerShell build step and move it up so that it is the first task to be executed.
    • Enter the source control path to your new script
  • Now add two new variables MajorVersion and MinorVersion
  • Update the Build number format, set it to $(BuildDefinitionName)_$(MajorVersion).$(MinorVersion).$(Year:yy)$(DayOfYear)$(Rev:.rr). Using this format we are guaranteed that the build number will always go up, if we just used $(DayOfYear) or something like that, the build number would reset at the beginning of each year.
  • Save and test your build.
  • Next, save the build as a template.

 

  • Now you can create a new build with version number and build number management already built in.
    • Create a new build
    • Go to the Custom tab
    • Select your template from the list of available templates
    • Press OK
    • Configure your new build, (Select the appropriate trigger, specify the source to get, projects/solutions to build, clean workspace, etc., etc.)
    • Go to the Variables tab and enter the desired Major and Minor version numbers.
    • Save the build definition
    • And Queue a build.

And that's it. You now have a build template that will set your version numbers and you build numbers consistently and keep them in sync. Try this for yourself and you will see just how quickly and easily you can manage version numbers as part of your vNext builds.