Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

During Azure build, want to get the revision number generated by azure pipeline to update the FileVersion of my projects

My Fileversion update script in AssemblyInfo.tt file is in below format.

"[assembly: AssemblyVersion("<#= this.MajorVersion #>.<#= this.MinorVersion #>.<#=DateTime.Now.Year%100#><#=DateTime.Now.DayOfYear/7+1#><#=(int)DateTime.Now.DayOfWeek#>.?")]"

In the place specified as "?", I want to get the rev:.r number generated by Azure Build. Or "?" should get auto-incremented for every Azure build of a day.

What is the better method I can follow to archive it.

like image 469
Deepak Sabastein Avatar asked Dec 21 '25 15:12

Deepak Sabastein


1 Answers

You can add a PowerShell script that does it:

$buildNumber = $env:Build_BuildNumber
$split = $buildNumber.Split('.')
$revision = $split[$split.Count - 1]
$assemblyFile = path/to/assembly/file # e.g. $(build.sourcesdirectory)/project/assmeblyinfo.cs
((Get-Content -path $assemblyFile -Raw) -replace "#>.?" , "#>.$($revision)") | Set-Content -Path $assemblyFile
like image 115
Shayki Abramczyk Avatar answered Dec 24 '25 04:12

Shayki Abramczyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!