32

Setting up a simple class library to build and publish to VSTS's own feed, I see this error when the NuGet package runs.

Could not find version number data in BUILD_BUILDNUMBER

I have the "Use Build number to version package" option ticked. Expected VSTS to just work.

1
  • Can you post your nuspec file? Commented Apr 14, 2016 at 18:34

4 Answers 4

40

The tip for "Use Build number to version package" states:

Will use the build number to version you package. Under General set the build format to be '$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)'

Following this did get me past this issue (and on to a new one).

Default value:

[Default value]

Correct Value:

[Correct Value]

Sign up to request clarification or add additional context in comments.

4 Comments

Was the new issue anything to do with paths too long? How did you fix it?
I figured min out, I was using a glob pattern to locate my .nuspec file for a Node.js project and the node_modules folder was creating paths far too long for Window's liking. Hardcoded the path to the .nuspec and that fixed it. Thanks for your answer. Got me to my next problem!
note that the Build number format option is now under the "Options" tab
you can do this in yaml by adding : name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
9

This is because your build number does not match the regex in "Nuget Packager" step. Following is the regex that nuget packager task used to find the build number. You can set your build number format base on this. General, the format like 1.2.3 or 1.2.3.4 would work.

Write-Verbose "Autoversion: Getting version number from build"
##Get Version from Build

# Regular expression pattern to find the version in the build number 
# and then apply it to the assemblies
$VersionRegex = "\d+\.\d+\.\d+(?:\.\d+)?"

Comments

1

If what you want is the major.minor.patch.unique-to-build then you use the Use the date and time option.

In yaml, the equivalent is

- task: NuGetCommand@2
  displayName: Pack
  inputs:
    command: 'pack'
    packagesToPack: '**/*.csproj'
    versioningScheme: 'byPrereleaseNumber'
    majorVersion: '1'
    minorVersion: '0'
    patchVersion: '0'

Comments

0

I had a variable in my .nuspec file:

<tags>Build#$build$</tags>

that was incorrectly parameterized in the package build step. With the package step open in the build editor, I expanded the 'Advanced' section added to 'Additional Build Properties' this text

build=$(Build.BuildNumber)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.