Skip to content

Instantly share code, notes, and snippets.

@Gimly
Created November 13, 2015 13:47
Show Gist options
  • Save Gimly/9f00a1adb03272b11d6e to your computer and use it in GitHub Desktop.
Save Gimly/9f00a1adb03272b11d6e to your computer and use it in GitHub Desktop.
# Use a regular expression to get "minor, major, fix, revision" from the BUILD_BUILDNUMBER environment variable
# the build process will automatically set the value of the environment variable to the correct build number
$VersionRegex = "\d+\.\d+\.\d+\.\d+"
$NewVersion = [regex]::matches($Env:BUILD_BUILDNUMBER,$VersionRegex)
Write-Host "Updating version of the application to the build version: " $NewVersion
$file = ".\SharedAssemblyInfo.cs"
$filecontent = Get-Content($file)
attrib $file -r
# Search in the "SharedAssemblyInfo.cs" file items that matches the version regex and replace them with the
# correct version number
$filecontent -replace $VersionRegex, $NewVersion | Out-File $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment