TFS Online - start $(Rev.r) from 0

2019-07-26 16:25发布

问题:

I am using $(Rev:.r) in my build number.

Major.Minor$(Rev:.r)

This works perfect and increments on every build and gets reset if the the major or minor version gets changed.

But the numbering starts at 1 and not 0. So the first build is not 1.0.0 but 1.0.1 which is not really what I am going for.

So is there a way to make the Revision start at 0?

Thanks for the help...

P.S. Unfortunately it is not possible to use Git and GitVersion in this project.

回答1:

No, this can't be achieved.

What is the Rev?

Use $(Rev:.rr) to ensure that every completed build has a unique name. When a build is completed, if nothing else in the build number has changed, the Rev integer value is incremented by one.

Source Link: Build number format

Moreover, anytime you change your Build Number in a TFS build, the revision resets to 1. It' by default, you could not change this value. Since if you could be able to set the value start from 0, it's also should be able to set it start from 100. This will mess up the build number.



回答2:

As a workaround to reset the revision number, you could create a clone of the existing build definition and kick off a new build with the recently created definition. This will initiate a new build starting at revision # 1.

Here is how to clone the build definition, click on the 3 dots next to the definition title under Build definitions page. Refer the screenshot below;

Click here to view screenshot - clone a definition

As like 1.0.0.1 if you have set the format to be 1.0.0$(rev:.r) in the build format field.

Otherwise resetting the revision # within a build definition isn't possible. I have tried deleting earlier builds and also tried manually setting the build number to 1.0.0.0 to reset but nothing worked.