functions/Increment-ModuleVersion.ps1
function Increment-ModuleVersion { [CmdletBinding()] Param( [Parameter(Mandatory=$true)] [string] $ManifestFilePath, [Parameter(Mandatory=$true)] [string] $BuildNumber ) begin {} process { try { $ver = (Test-ModuleManifest $ManifestFilePath | Select-Object Version | Select-Object -First 1) Write-Verbose "Revision is: $($ver.Version.Revision)" if($ver.Version.Revision -eq -1) { Write-Verbose "Process has found a 3 part version" $xVer = New-Object System.Version($ver.Version.Major, $ver.Version.Minor, $BuildNumber) } else { Write-Verbose "Process has found a 4 part version" $xVer = New-Object System.Version($ver.Version.Major, $ver.Version.Minor,$ver.Version.Build, $BuildNumber) } Write-Verbose "version number is $($xver.ToString())" Update-ModuleManifest -Path $ManifestFilePath -ModuleVersion $xVer.ToString() } catch { Write-Host $_.Exception.Message } } end {} } |