Last active
March 19, 2022 17:06
-
-
Save blakeja/5655fe2ac52ff26fdec9ffa481c18dd9 to your computer and use it in GitHub Desktop.
Update revision in AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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