After executing the build pipeline, I add a tag to the specific git commit to track the deployed code. This is something that is built-in the Azure DevOps pipeline functionality through the Tag Sources:
Originally I used the $(build.buildNumber)
variable to tag the code. But I updated my project to use a VersionPrefix value inside my directory.build.props file:
Of course this VersionPrefix value is not available as a variable inside my Azure DevOps pipeline. So the question is how can I create a new pipeline variable?
I solved this by creating a small Powershell script that reads the value from the Directory.Build.props
file and uses the task.setvariable
macro to create a pipeline variable:
More information: Set variables in scripts - Azure Pipelines | Microsoft Learn