I have a variable nugetVersion
to which I assign a value depending on if we’re in master branch or a feature branch, and later on in the Packaging step it won’t be recognized. The pipeline outputs No value was found for the provided environment variable.
Here’s my .yml file
trigger:
- master
pool:
vmImage: ubuntu-latest
variables:
major: '1'
minor: '1'
revision: $[counter(variables['minor'], 1)] # This will get reset every time minor gets bumped.
group: 'nuget-version-group'
name: nugetVersion
${{ if eq( variables['Build.SourceBranchName'], 'master' ) }}:
value: '$(major).$(minor).$(revision)'
${{ else }} :
value: '$(major).$(minor).$(revision)-$(Build.SourceBranchName)'
steps:
- script: echo $nugetVersion
displayName: 'Output nugetVersion'
- task: DotNetCoreCLI@2
displayName: Restoring
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: '---'
- task: DotNetCoreCLI@2
displayName: Packaging
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'byEnvVar'
versionEnvVar: nugetVersion
- task: NuGetAuthenticate@1
displayName: Authenticate
- task: DotNetCoreCLI@2
displayName: Pushing
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '---'
Before I was using a conditional for the nugetVersion, it would correctly recognize it during the Packaging step. it used to look like this:
variables:
major: '1'
minor: '1'
revision: $[counter(variables['minor'], 1)] # This will get reset every time minor gets bumped.
nugetVersion: '$(major).$(minor).$(revision)'