ViBi
ViBi

Reputation: 637

Nuget pack using versioningScheme ='byEnvVar' not working

I have a pipeline job with 2 tasks in it

Task 1 (Powershell@2): I am updating the build number to say "1.0.0.0" using command

$version = "1.0.0.0"

Write-Host "##vso[build.updatebuildnumber]$version"

I can see that build version gets updated for this pipeline run.

Task 2 (NuGetCommand@2): I am using pack command to create the nuget package

- task: NuGetCommand@2
  displayName: Nuget Pack
  inputs:
    command: 'pack'
    packagesToPack: '**/${{parameters.packageid}}.nuspec'
    versioningScheme: 'byEnvVar'
    versionEnvVar: BUILD_BUILDVERSION
    configuration: '$(buildConfiguration)'

In task2, it is giving error "##[error]No value was found for the provided environment variable."

I have tried versionEnvVar: Build.BuildVersion as well but it simply does not work.

Here is the documentation link from MS NugetCommand

Can someone please point out what I am doing wrong here.

Upvotes: 1

Views: 4658

Answers (1)

Leo Liu
Leo Liu

Reputation: 76910

Nuget pack using versioningScheme ='byEnvVar' not working

As your description, you need using Build.BuildNumber instead of BUILD_BUILDVERSION, like:

versioningScheme: 'byEnvVar'
versionEnvVar: Build.BuildNumber

Besides, if you want use the BuildNumber as the package version, you could using the:

versioningScheme: byBuildNumber

Upvotes: 0

Related Questions