Forked from rosberglinhares/IncrementAssemblyVersion.ps1
Created
April 10, 2018 19:36
-
-
Save claudiosteuernagel/ea4df4b3ff9df660890c30c7be7965f9 to your computer and use it in GitHub Desktop.
Powershell script to increment assembly version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param ( | |
[Parameter(Mandatory=$true)] | |
[string] $AssemblyInfoPath | |
) | |
$ErrorActionPreference = 'Stop' # Stops executing on error instead of silent continue. | |
Set-StrictMode -Version Latest # Enforces coding rules in expressions, scripts, and script blocks. Uninitialized variables are not permitted. | |
$fileContent = Get-Content $AssemblyInfoPath | Out-String | |
$assemblyVersionCapturePattern = 'AssemblyVersion\("\d+\.\d+\.\d+\.(\d+)"\)' | |
$assemblyVersionReplacePattern = '(AssemblyVersion\("\d+\.\d+\.\d+\.)\d+("\))' | |
$fileVersionReplacePattern = '(AssemblyFileVersion\("\d+\.\d+\.\d+\.)\d+("\))' | |
$currentRevision = [int][RegEx]::Match($fileContent, $assemblyVersionCapturePattern).Groups[1].Value | |
$newRevision = $currentRevision + 1 | |
$fileContent = [RegEx]::Replace($fileContent, $assemblyVersionReplacePattern, '${1}' + $newRevision + '${2}') | |
$fileContent = [RegEx]::Replace($fileContent, $fileVersionReplacePattern, '${1}' + $newRevision + '${2}') | |
$fileContent | Out-File $AssemblyInfoPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment