locked
How do I reset $Rev for my build numner? RRS feed

  • Question

  • Hi all,

    Currently in my Build Definition I have the Build Number set to 1.0.0$Rev.  So, my build is now something like 1.0.0.733, for example.  When I move to 1.0.1$rev or 1.1.0$rev, how do I set revision back to 0, or is that somehow detected  and done automatically?

    Any info greatly  appreciated.

    Thursday, February 25, 2016 12:22 PM

Answers

  • Hi NitLions,  

    Thanks for your reply.

    That works in XAML build definition too, I tested it in TFS 2015 environment.

    If you change your build number format to 1.0.1$(Rev:.r), then next build number will start from 1.0.1.1 automatically.

    You can create a test XAML build definition in your TFS Server, then test this scenario and check result.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, February 29, 2016 5:43 AM
    Moderator

All replies

  • Hi NitLions,  

    Thanks for your post.

    If your first build number format is 1.0.0$(Rev:.r) and latest build number is 1.0.0733 now, after you change build number format to 1.1.0$(Rev:.r), the next build number will start from 1.1.0.1 automatically.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 26, 2016 6:01 AM
    Moderator
  • Thank you!  I should point I'm using a XAML build template and not vNext if that makes a difference.

    I read that in the past that this had to be done manually.  When one wanted to reset Rev, the build number setting should be set to 1.1.0.0, run build then set the build number to 1.1.0. $(Rev:.r).  The next build would then be 1.1.0.1 and increment from there.

    I'm wondering if things would still work that way.  We derive our Windows Installer package version from the TFS build version.  Windows Installer only recognizes or utilizes a three position version, #.#.#.  So we have an algorithm to create an installer package version and would need to NOT reset the revision if we move to 1.0.1.  So if our last version was 1.0.0.733 I would need the first build of 1.0.1 to be 1.0.1.744.  Confusing, I know.

    So could I manually set the first build of 1.0.1 to 1.0.1.744, build, then change to 1.0.1.($Rev:.r) to have the next build become 1.0.0.745?

    Friday, February 26, 2016 12:30 PM
  • Hi NitLions,  

    Thanks for your reply.

    That works in XAML build definition too, I tested it in TFS 2015 environment.

    If you change your build number format to 1.0.1$(Rev:.r), then next build number will start from 1.0.1.1 automatically.

    You can create a test XAML build definition in your TFS Server, then test this scenario and check result.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, February 29, 2016 5:43 AM
    Moderator
  • Windows Installer only recognizes or utilizes a three position version, #.#.#.  So we have an algorithm to create an installer package version and would need to NOT reset the revision if we move to 1.0.1.  So if our last version was 1.0.0.733 I would need the first build of 1.0.1 to be 1.0.1.744.  Confusing, I know.

    So could I manually set the first build of 1.0.1 to 1.0.1.744, build, then change to 1.0.1.($Rev:.r) to have the next build become 1.0.0.745?

    Yes, you can override the generated build number and save it back.

    I have two arguments on the template:

    • InProductVersionKernel (for the first digits of your build number 1.0.1)
    • InBuildJobNumberOverride (for the number that you want to increase the last digit to)

    I have one new Variable on the template:

    • BuildJobNumber int32 scoped to the whole sequence because I use this later for other purposes

    On the Metadata argument you press the ... button and set InBuildJobNumberOverride to "Always show the parameter" and "not required" (so the user can set that parameter when queueing a build.

    In the Template:

    Right after Update Build Number you add:

    1. Add an A*B assignment and you give BuildJobNumber=CInt(BuildDetail.BuildNumber.Substring(BuildDetail.BuildDefinition.Name.Length + ProductVersionKernel.Length + 2))  I have plus 2 because I use the name plus one underscore and one period in the .rrrr

    2. Add an If condition If BuildJobNumberOverride > BuildJobNumber then on the true side add  four things:

    • Assign A*B BuildJobNumber=BuildJobNumberOverride
    • Assign A*B BuildDetail.BuildNumber=String.Concat(BuildDetail.BuildNumber.Substring(0, BuildDetail.BuildNumber.Length - 4), BuildJobNumber.ToString(format:="D4"))

    This changes the build name to have the new number, mine is four digits long (.rrrr) so that is why I format it to 4 digits and plop it on the string in place of the last four digits

    • A*B Assign BuildDetail.BuildNumber=String.Concat(BuildDetail.BuildNumber.Substring(0, BuildDetail.BuildNumber.Length - 4), BuildJobNumber.ToString(format:="D4"))

    This changes the build name to have the new number, mine is four digits long (.rrrr) so that is why I format it to 4 digits and plop it on the string in place of the last four digits

    • Add another "Update Build Number" tool from the toolbox and in the properties set the BuildNumberFormat to BuildDetail.BuildNumber

    This changes the number behind the scenes somewhere so that subsequent builds will increment in sequence from your override number.

    In the Build Definition:

    Edit the build definition, Refresh the template, then your arguments appear in the Misc category on the Process page.

    Set InProductVersionKernel to the first three digits of your build number with the periods 1.0.1

    Set the InBuildJobNumberOverride to 0 or some seed number that you do not want to go below

    Set Build Number Format to something like this: $(BuildDefinitionName)_1.0.1$(Rev:.rrrr)  You have to make the InProductVersionKernel and the first three digits of the number in this variable match.

    When you queue a build:

    If you pick the Parameters tab page you can override the build number with a higher number, or leave it at the seed number to just get the next number automatically.


    • Edited by Loraine C Wednesday, March 16, 2016 8:53 PM
    Wednesday, March 16, 2016 8:51 PM