Search code examples
tfsazure-devopstfsbuild

How to apply the build number format to shelveset builds in tfs?


I have a TFS build definition with the

Process > Basic > Build Number Format parameter set to

1.1.2-alpha$(Rev:.r)

This works fine whenever I build from the 'Latest Sources' and the build agent applies the correct version number (1.1.2-alpha1 and so on). However, when I try to build from a shelveset with the same build definition, the build fails with the following error:

'31927' is not a valid version string.

So, how can I make sure that the build agent applies the same naming pattern when building from a shelveset?

Error message:

enter image description here


Solution

  • The error is caused by the nuget pack task in your build process. You used the build number to version the nuget package but the build number "31927" does not meet the Nuget Versioning.

    When you queue a build with shelveset, the build number always use the format: Build N. It does not read the settings you configured in "Build Number Format". Refer to this link for details: Private Build.

    The completed build is named by using the format Build N where N is a unique integer value. This format differs from that of public builds, which you specify by using the Build Number Format parameter.

    That's means that, to avoid this issue, you need to use some other ways to version your nuget package.