Azure Pipelines, remove certain characters from build number

Viewed 677

We use GitVersion which in the .yml file has tag alpha for the develop branch. We also use MSBuild to make ClickOnce app and we want to use the GitVersion version for the app version. As far as I know GitVersion updates the build number, so in theory the version can be set with /p:AssemblyVersion=${Build.BuildNumber}, but the format of the version is [major].[minor].[build]-{tag}.[revision], e.g. 2.1.0-alpha.5.

Is it possible to set the AssemblyVersion to 2.1.0.5 so the build won't fail?

1 Answers

You can add a simple script that removes the -alpha from the version and update the build number:

$buildNumber = $env:Build_BuildNumber
$version = $buildNumber -creplace '-.....', ''
Write-Host "##vso[build.updatebuildnumber]$version"
Related