Skip to content

Instantly share code, notes, and snippets.

@edwinf
Created July 6, 2012 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwinf/3061260 to your computer and use it in GitHub Desktop.
Save edwinf/3061260 to your computer and use it in GitHub Desktop.
update guid attribute on an assemblyinfo.cs file
if ($args.Length -eq 1)
{
if (Test-Path $args[0])
{
$tempFile = $args[0]+".tmp";
Write-Host "Getting content from: "$args[0];
Write-Host "Writing to temp file: " $tempFile;
$newGuid = [System.Guid]::NewGuid().Guid;
$newGuid = "Guid(""" + $newGuid + """)";
Write-Host "Replacing with: " $newGuid;
Get-Content $args[0] |
%{$_ -replace 'Guid\(([^\)]+)\)',$newGuid} > $tempFile
move-item $tempFile $args[0] -force;
}else{
Write-Host "File Not Found";
}
}else{
Write-Host "Provide file path as argument";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment