I have two pipelines, release and prerelease.
In release pipeline version set up like this, the counter for the patch and manually set major/minor version:
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
majorVersion: '1'
minorVersion: '1'
patchVersion: $[counter(format('{0}.{1}', variables['majorVersion'], variables['minorVersion']), 0)]
productVersion: $[format('{0}.{1}.{2}', variables['majorVersion'], variables['minorVersion'], variables['patchVersion'])]
In prerelease pipeline I manual check what is the version for all major, minor and patch from the latest release, I only add Build.BuildNumber in the end to declare it as a prerelease:
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
majorVersion: '1'
minorVersion: '1'
patchVersion: '2' <!-- if the last release patch version was 1, in the next prerelease I need here 2-->
productVersionBeta: $[format('{0}.{1}.{2}-{3}', variables['majorVersion'], variables['minorVersion'], variables['patchVersion'], variables['Build.BuildNumber'])]
In the end I pack and push NuGet.
What I would like to have in my prerelease pipeline is:
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
majorVersion: $(SOMEHOW_GET_LATEST_MAJOR_RELEASE_VERSION)
minorVersion: $(SOMEHOW_GET_LATEST_MINOR_RELEASE_VERSION)
patchVersion: $(SOMEHOW_GET_LATEST_PATCH_RELEASE_VERSION) + 1
productVersionBeta: $[format('{0}.{1}.{2}-{3}', variables['majorVersion'], variables['minorVersion'], variables['patchVersion'], variables['Build.BuildNumber'])]
Is it possible to get the behavior as described with only yaml config because I didn't find anything about it?
If it's not possible to do just through the config then I found this REST API The Artifact Details - Get Package Version. Is there a clean way to implement it inside the pipeline for the same purposes?