This can be done without doing parsing and error handling with the following YAML:
trigger:
tags:
include:
- 0.*
- 1.*
- 2.*
- 3.*
- 4.*
- 5.*
- 6.*
- 7.*
- 8.*
- 9.*
pool: 'LocalWindows'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: NuGetCommand@2
inputs:
command: 'pack'
packagesToPack: '**/Source/*.vbproj'
versioningScheme: 'byEnvVar'
versionEnvVar: 'BUILD_SOURCEBRANCHNAME'
includeSymbols: true
The special thing is, that you must have a trigger which only listens on tags and then you can use the envvar BUILD_SOURCEBRANCHNAME.
You can adjust the tag-includes as you wish.