Skip to content

Instantly share code, notes, and snippets.

@blakeja
Last active March 19, 2022 17:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blakeja/5655fe2ac52ff26fdec9ffa481c18dd9 to your computer and use it in GitHub Desktop.
Save blakeja/5655fe2ac52ff26fdec9ffa481c18dd9 to your computer and use it in GitHub Desktop.
Update revision in AssemblyInfo.cs
param(
[string]$file,
[string]$revision
)
$pattern = '^\[assembly: AssemblyVersion\("(.*)"\)\]$'
(Get-Content $file -Encoding UTF8) | ForEach-Object {
if ($_ -match $pattern)
{
$fileVersion = [version]($matches[1] -replace "\*","0")
$newVersion = "{0}.{1}.{2}.{3}" -f $fileVersion.Major, $fileVersion.Minor, $fileVersion.Build, $revision
'[assembly: AssemblyVersion("{0}")]' -f $newVersion
Write-Host "Updating version from $fileVersion to $newVersion in $file"
}
else
{
$_
}
} | Set-Content $file -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment