|
| 1 | +<# .SYNOPSIS |
| 2 | + Updates the version of all UnitsNet.Extensions projects. |
| 3 | +.DESCRIPTION |
| 4 | + Updates the <Version> property of the .csproj project files. |
| 5 | +.PARAMETER set |
| 6 | + Set new version |
| 7 | +.PARAMETER bump |
| 8 | + Bump major, minor, patch or semver suffix number. Only one can be specified at a time, and bumping one part will reset all the lesser parts. |
| 9 | +.EXAMPLE |
| 10 | + Set new version. |
| 11 | + -v 2.3.4-beta3: 1.0.0 => 2.3.4-beta3 |
| 12 | +.EXAMPLE |
| 13 | + Bump the major, minor, patch or suffix part of the version. |
| 14 | + -b major: 1.2.3-alpha1 => 2.0.0 |
| 15 | + -b minor: 1.2.3-alpha1 => 1.3.0 |
| 16 | + -b patch: 1.2.3-alpha1 => 1.2.4 |
| 17 | + -b suffix: 1.2.3-alpha => 1.2.3-alpha2 |
| 18 | + -b suffix: 1.2.3-alpha2 => 1.2.3-alpha3 |
| 19 | + -b suffix: 1.2.3-beta2 => 1.2.3-beta3 |
| 20 | + -b suffix: 1.2.3-rc2 => 1.2.3-rc3 |
| 21 | +
|
| 22 | +.NOTES |
| 23 | + Author: Lu Li |
| 24 | + Date: Jan 15, 2020 |
| 25 | + Based on original work by Luis Rocha from: http://www.luisrocha.net/2009/11/setting-assembly-version-with-windows.html |
| 26 | + #> |
| 27 | + [CmdletBinding()] |
| 28 | + Param( |
| 29 | + [Parameter(Mandatory=$true, Position=0, ParameterSetName="set", HelpMessage="Set version string")] |
| 30 | + [Alias("version")] |
| 31 | + [string]$setVersion, |
| 32 | + |
| 33 | + [Parameter(Mandatory=$true, Position=0, ParameterSetName="bump", HelpMessage="Bump one or more version parts")] |
| 34 | + [Alias("bump")] |
| 35 | + [ValidateSet('major','minor','patch','suffix')] |
| 36 | + [string]$bumpVersion |
| 37 | + ) |
| 38 | + |
| 39 | + function Help { |
| 40 | + "Sets the AssemblyVersion and AssemblyFileVersion of AssemblyInfo.cs files`n" |
| 41 | + ".\SetVersion.ps1 [VersionNumber]`n" |
| 42 | + " [VersionNumber] The version number to set, for example: 1.1.9301.0" |
| 43 | + " If not provided, a version number will be generated.`n" |
| 44 | + } |
| 45 | + |
| 46 | +# Import functions: Get-NewProjectVersion, Set-ProjectVersion, Invoke-CommitAndTagVersion |
| 47 | +Import-Module "$PSScriptRoot\set-version.psm1" |
| 48 | + |
| 49 | +$root = Resolve-Path "$PSScriptRoot\.." |
| 50 | +$paramSet = $PsCmdlet.ParameterSetName |
| 51 | +$projFile = "$root\UnitsNet.NumberExtensions\UnitsNet.NumberExtensions.csproj" |
| 52 | +$versionFiles = @($projFile) |
| 53 | +$projectName = "UnitsNet.NumberExtensions" |
| 54 | + |
| 55 | +# Use UnitsNet.Common.props version as base if bumping major/minor/patch |
| 56 | +$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion |
| 57 | + |
| 58 | +Set-ProjectVersion $projFile $newVersion |
| 59 | +Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion |
0 commit comments