In a project where we use ASP.NET 5 (or ASP.NET Core 1.0) we wanted to use dynamic versioning in the build.
As described here you can use the asterisk (*) for the version in the project.json file
If you set the environment variable DNX_BUILD_VERSION to a value, the asterisk will be replaced with this value.
All fine, but when you run this on the build server it seems that the asterisk will only be replaced on the first run but the second and following build the new value of the environment variable is ignored.
To overcome this problem, I have created a simple powershell script, that replaces tha asterisk with a value of choice.
The powershell parses the project.json and replaces the asterisk with a buildname-buildversion (this can be anything). The script can be found here on Github. An example project.json is there as well.
You can run the powershell on the command line by running
.\Set-BuildVersion.ps1 -filePath .\project.json –buildName buildName -buildNumber 20160101
You can then add this powershell as a build task in your pipeline
Hope this helps !
Comments are closed.