Many of you might have read some great blog posts from Freddy Kristensen on his blog. If not I can highly recommend reading through this blog series on how to get Azure DevOps setup to work with your Extension/App development for Microsoft Dynamics 365 Business Central.
Here is a list of the blogs released at this time:
Part 1, Part 2, Part 3, Part 4 & Part 5
One of the things I was missing my self in this serie was to be able to change the way the build numbers are generated. Freddy used the default numbering which is YYYYMMDD.R where YYYY is the Year, MM the Month, DD the Day and R the revision number for any given date. This is the stamp the build is getting inside Microsoft Azure DevOps.
You can change this very simple with adding the following to the IC.yml file at the very top.
name: $(Build.BuildID)
Here I set the naming to the internal build ID generated by Azure DevOps, but you can of course also set it to something of your own choosing. The link blow gives you a huge selection of options for setting the build number differently.
https://docs.microsoft.com/en-us/azure/devops/pipelines/build/options
This only resolves half the problem. If you are like me you would want to update the version number in the app.json file too.
I did that by adding a new script called “SetVersionNo.ps1” in the scripts folder.
$AppJsonFile = “.\app\app.json”
$AppJsonObject = Get-Content -Raw -Path $AppJsonFile | ConvertFrom-Json
$AppJsonObject.Version = $AppJsonObject.Version -replace “.{3}$”
$AppJsonObject.Version = $AppJsonObject.Version+$env:Build_BuildID + ‘.0’
$AppJsonObject | ConvertTo-Json | set-content $AppJsonFile
$TestAppJsonFile = “.\test\app.json”
$TestAppJsonObject = Get-Content -Raw -Path $TestAppJsonFile | ConvertFrom-Json
$TestAppJsonObject.Version = $TestAppJsonObject.Version -replace “.{3}$”
$TestAppJsonObject.Version = $TestAppJsonObject.Version+$env:Build_BuildID + ‘.0’
$TestAppJsonObject | ConvertTo-Json | set-content $TestAppJsonFile
This script updates the current version number I use “13.0.0.0” by removing the last 3 digits and replacing them by the BuildID and “.0”
In other words if the BuildID is 1234 than the version number is set to “13.0.1234.0.
Again you can do your own thing here by using the link from above and build the version number in a different way.
The only missing is to add a task to the CI.yml file to execute the PowerShell Script as the first task. This is done by adding the following right after the “steps:” in the CI.yml file.
This will run the PowerShell Script from earlier and automatically set the correct version number before building the Extension. One less thing for the developer to do manually.
We can agree or disagree if that is the right way of numbering an extension, however it works for me and I hope it inspire all of you to do your own thing.
Enjoy.
Pingback: Adding the Test App to the Artifacts | Thinking NAV – Thinking Differently
Pingback: Adding the Test App to the Artifacts - Thinking NAV – Thinking Differently - Dynamics 365 Business Central/NAV User Group - Dynamics User Group