AzureDevOps/VSTS Build - Could not find version nu

2019-03-09 18:16发布

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.

3条回答
我命由我不由天
2楼-- · 2019-03-09 18:48

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)
查看更多
姐就是有狂的资本
3楼-- · 2019-03-09 19:02

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]

查看更多
4楼-- · 2019-03-09 19:04

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+)?"
查看更多
登录 后发表回答