In this guide, we’ll set up an Azure DevOps pipeline that automatically tags the latest commit in the main branch with the version number from a Dataverse Solution.xml file. This setup helps track solution versions in Git, making it easy to locate specific versions of your Dataverse solution over time.
Note: This tagging process isn’t intended for release tags. The tag is moved to the latest commit that matches the version in
Solution.xml
, ensuring that unrelated changes (like config updates) don’t leave the version tag on older commits. However, because this pipeline deletes and recreates tags, it can cause issues if used with release tags or if others rely on specific tags for deployments. For production or release tags, it’s safer to create new versioned tags, likev1.0.1
orrelease-v1.0.2
, for each update rather than overwriting existing tags.
Step 1: Create the Pipeline YAML File
In your Azure DevOps Git repository, where your Dataverse solution files are unpacked, create a new pipeline file. For this example we’ll use pipelines\git-tag-solution-version.yml
.
Add the following content to the YAML file:
The PowerShell script in the pipeline does the following:
- Configures Git with the user’s email and name for tagging.
- Checks if
Solution.xml
exists; exits if not found. - Reads the solution name and version from
Solution.xml
. - Combines the solution name and version to create a tag name.
- Checks if the tag already exists, deletes it if so, to keep the tag on the latest commit.
- Tags the latest commit with the solution version and pushes it to the remote repository.
Step 2: Set Up the Pipeline in Azure DevOps
- Go to your Azure DevOps project.
- Navigate to Pipelines
- Click New pipeline.
- Select Azure Repos Git and choose your repository.
- Select Exisiting Azure Pipelines YAML file.
- Select the branch and path where you created the YMAL file, then click Continue.
- Click the dropdown arrow next to Run and select Save.
- To rename the pipeline, click the vertical ellipsis on the top right, choose Rename/move pipeline, and name it
git-tag-solution-version
, then click Save.
Step 3: Test the Pipeline
- Make a change to files, commit and push your changes to the remote repository.
- If you update the solution version you should see a new tag created with the latest version.
- If you update files other than the solution file verion then you should see the solution git tag move to the latest commit.