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 da
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:
[]
Correct Value:
[]
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+)?"
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'
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)