Skip to content

Instantly share code, notes, and snippets.

@altu
Created June 25, 2015 12:54
Show Gist options
  • Save altu/0ba467c4f42e19645e8e to your computer and use it in GitHub Desktop.
Save altu/0ba467c4f42e19645e8e to your computer and use it in GitHub Desktop.
PowerShell function for updating the VDProj's version information
function Update-vdproj-version([version] $ver, [string] $filename) {
$productCodePattern = '\"ProductCode\" = \"8\:{([\d\w-]+)}\"'
$packageCodePattern = '\"PackageCode\" = \"8\:{([\d\w-]+)}\"'
$productVersionPattern = '\"ProductVersion\" = \"8\:[0-9]+(\.([0-9]+)){1,3}\"'
$productCode = '"ProductCode" = "8:{' + [guid]::NewGuid().ToString().ToUpper() + '}"'
$packageCode = '"PackageCode" = "8:{' + [guid]::NewGuid().ToString().ToUpper() + '}"'
$productVersion = '"ProductVersion" = "8:' + $ver.ToString(3) + '"'
(Get-Content $filename) | ForEach-Object {
% {$_ -replace $productCodePattern, $productCode } |
% {$_ -replace $packageCodePattern, $packageCode } |
% {$_ -replace $productVersionPattern, $productVersion }
} | Set-Content $filename
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment