Skip to content

Instantly share code, notes, and snippets.

@grenade
Last active August 29, 2015 13:56
Show Gist options
  • Save grenade/8973223 to your computer and use it in GitHub Desktop.
Save grenade/8973223 to your computer and use it in GitHub Desktop.
param(
[string] $assemblyInfoFile,
[hashtable] $parameters
)
Write-Host ("`$assemblyInfoFile: {0}" -f $assemblyInfoFile)
foreach($key in $($parameters.Keys)){
if($parameters[$key] -ne $null){
$assemblyInfo = Get-Content $assemblyInfoFile
$pattern = ('^\[assembly: {0}\("(.*)"\)\]' -f $key)
$oldValue = ($assemblyInfo | Select-String -Pattern $pattern | % { $_.Matches } ).Groups[1].Value
$match = ('[assembly: {0}("{1}")]' -f $key, $oldValue)
$replace = ('[assembly: {0}("{1}")]' -f $key, $parameters[$key])
$assemblyInfo | ForEach-Object { % {$_ -Replace $match, $replace } } | Set-Content $assemblyInfoFile
Write-Host ("{0} changed from: '{1}', to: '{2}'." -f $key, $oldValue, $parameters[$key])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment