2
votes

In Team City, there is the concept of a build counter. The counter is incremented each time a build is performed and is scoped to a single build definition - so invoking build definition A will not update the counter for build definition B and vice-versa.

In Visual Studio Team Services (was Visual Studio Online) build, there is a $Env:BUILD_BUILDNUMBER but this number seems to be scoped globally to all build definitions.

In order to label my builds and the subsequent nuget packages using the semver major.minor.patch I would like access to a teamcity like build counter, scoped to a single build definition. I'd rather not use a script to update some file or http based per build store, which feels like a lot of work for something which is so simple out of the box in Team City.

1

1 Answers

2
votes

You can update "Build number format" under "General" tab in your build definition settings to use "$(Rev:.r)" as the build number like following:

major.minor$(Rev:.r)

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.

If you want to show prefix zeros in the number, you can add additional r characters. For example, specify $(rev:.rr) if you want the Rev number to begin with 01, 02, and so on.

Refer to this link for details: Build Number Format.