Forked from rosberglinhares/GetNextAssemblyVersion.ps1
Created
April 10, 2018 19:36
-
-
Save claudiosteuernagel/23ebc5b84ce59c58abd610ed6f063cc5 to your computer and use it in GitHub Desktop.
Powershell script to increment and get the assembly version to be used with the EnvInject Jenkins plugin
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, | |
[string] $PropertiesFilePath = 'EnvInjectProperties.txt', | |
[string] $PropertyName = 'NEXT_VERSION' | |
) | |
$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 | |
$assemblyVersionPattern = 'AssemblyVersion\("(\d+\.\d+\.\d+\.\d+)"\)' | |
$currentVersionStr = [RegEx]::Match($fileContent, $assemblyVersionPattern).Groups[1].Value | |
$currentVersion = New-Object Version($currentVersionStr) | |
$newVersion = New-Object Version($currentVersion.Major, $currentVersion.Minor, $currentVersion.Build, ($currentVersion.Revision + 1)) | |
Add-Content $PropertiesFilePath "$PropertyName=$newVersion" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment