Skip to content

Instantly share code, notes, and snippets.

@adamwitko
Last active August 29, 2015 14:17
Show Gist options
  • Save adamwitko/2049099b65fdf7670171 to your computer and use it in GitHub Desktop.
Save adamwitko/2049099b65fdf7670171 to your computer and use it in GitHub Desktop.
Powershell AssemblyInfo patcher example
$Version = "5.1.2"
$NewVersion = 'AssemblyVersion("' + $Version + '")';
$NewFileVersion = 'AssemblyFileVersion("' + $Version + '")';
Get-ChildItem .\ -Recurse -Filter AssemblyInfo.cs | % `
{
$FilePath = $_.FullName;
$TmpFile = $filePath + ".tmp"
Get-Content $FilePath |
% { $_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
% { $_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion } > $TmpFile
Move-Item $TmpFile $FilePath -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment