Issue
I want to update my version number in AssemblyInfo.cs with the build number of Azure DevOps (VSTS).
Does anyone know how I can do that through PowerShell?
Solution
The best way to do it is with Assembly Info Extension, and use the variable $(Build.BuildNumber)
in the version field.
But if you want to use your own PowerShell script you can do it with this script:
$buildNumber = "$env:Build_BuildNumber"
$pattern = '\[assembly: AssemblyVersion\("(.*)"\)\]'
$AssemblyFiles = Get-ChildItem . AssemblyInfo.cs -rec
foreach ($file in $AssemblyFiles)
{
(Get-Content $file.PSPath) | ForEach-Object{
if($_ -match $pattern){
'[assembly: AssemblyVersion("{0}")]' -f $buildNumber
} else {
# Output line as is
$_
}
} | Set-Content $file.PSPath
}
Answered By - Shayki Abramczyk Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.