Skip to content

Instantly share code, notes, and snippets.

@swade1987
Created February 12, 2016 15:58
Show Gist options
  • Save swade1987/5436443d5193b981311d to your computer and use it in GitHub Desktop.
Save swade1987/5436443d5193b981311d to your computer and use it in GitHub Desktop.
assembly
#-------------------------------------------------------------------------------
# Update version numbers of AssemblyInfo.cs
#-------------------------------------------------------------------------------
function Update-AssemblyInfoFiles ([string] $version) {
$assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
$fileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
$assemblyVersion = 'AssemblyVersion("' + $version + '")';
$fileVersion = 'AssemblyFileVersion("' + $version + '")';
Get-ChildItem -r -filter AssemblyInfo.cs | ForEach-Object {
$filename = $_.Directory.ToString() + '\' + $_.Name
$filename + ' -> ' + $version
# If you are using a source control that requires to check-out files before
# modifying them, make sure to check-out the file here.
# For example, TFS will require the following command:
# tf checkout $filename
(Get-Content $filename) | ForEach-Object {
% {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
% {$_ -replace $fileVersionPattern, $fileVersion }
} | Set-Content $filename
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment