Skip to content

Instantly share code, notes, and snippets.

@vsliouniaev
Created February 11, 2016 16:18
Show Gist options
  • Save vsliouniaev/6b159484590f009102dc to your computer and use it in GitHub Desktop.
Save vsliouniaev/6b159484590f009102dc to your computer and use it in GitHub Desktop.
param(
[Parameter(mandatory=$true)]
[ValidatePattern('[^"]+')]
[string]$version
)
# Jump up one directory up from where the script file is located
Push-Location ((Split-Path $MyInvocation.MyCommand.Path) + '\..')
function UpdateDevInfo([string]$fileLocation)
{
$githash = [string](git rev-parse HEAD)
$content = (get-content $fileLocation)
$content = ForEach-Object {
$content -replace "AssemblyFileVersion`\(`"[^`"]+'`\)","AssemblyFileVersion(`"$githash`")"
}
$content = ForEach-Object {
$content -replace "AssemblyInformationalVersion`\(`"[^']+`"`\)","AssemblyInformationalVersion(`"$version`")"
}
Set-Content $fileLocation $content
}
UpdateDevInfo("path\to\assemblyinfofile1.cs")
UpdateDevInfo("path\to\assemblyinfofile2.cs")
Pop-Location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment