I am working with Azure Pipelines and need to upload a file to Azure artifacts in one stage (build), and then download that same package with that same version in another stage (deploy). So far I have done this by using the Universal Package task for both upload and download, so I upload the package using the option versionOption: 'patch' in the build stage and download the package in the deploy stage using vstsPackageVersion: '0.0.*'.
This was an OK solution until I faced the issue of running two builds one after another that upload to the same Azure artifacts feed, and since I have set up an approval between the build and deploy stages, both runs of the pipeline will result in the deployment of the latest artifact pushed to the feed.
After some investigation I have found that the Universal Package upload task has this option called publishedPackageVar that saves the name and version of the uploaded artifact in a variable. I could not find any documentation on this option, but from what I can see it stores the name and version as a string, separated by a space character: <artifact_name> <major>.<minor>.<patch>, and the vstsPackageVersion requires only the <major>.<minor>.<patch> part.
My question is: Has anyone used this publishedPackageVar option for a similar reason and what is the best way for it to be passed to the vstsPackageVersion option of the Universal Package download task?
All solutions I can think of require some ugly, multi-step workarounds (like getting the version from the variable with sed and storing it as a new variable) which will just make my pipeline less readable.