Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AzureDevOps/VSTS Build - Could not find version number data in BUILD_BUILDNUMBER

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.

like image 873
Luke Puplett Avatar asked Apr 14 '16 18:04

Luke Puplett


People also ask

Where is $( build SourcesDirectory?

$(Build. SourcesDirectory) : The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s By default, new build definitions update only the changed files. You can modify how files are downloaded on the Repository tab.

What is build number in Azure DevOps?

Build numbers in Azure DevOps For example, Microsoft's Build Number format documentation gives an example: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:. r) will result in a version number like Fabrikam_CIBuild_main_20090805.

What is build ArtifactStagingDirectory?

Build.ArtifactStagingDirectory. The local path on the agent where any artifacts are copied to before being pushed to their destination. For example: c:\agent_work\1\a. A typical way to use this folder is to publish your build artifacts with the Copy files and Publish build artifacts tasks. Note: Build.


2 Answers

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]

like image 183
Frank V Avatar answered Oct 06 '22 11:10

Frank V


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+)?"
like image 9
Eddie Chen - MSFT Avatar answered Oct 06 '22 12:10

Eddie Chen - MSFT