< Back

New-SemanticVersion

Sat Jan 18, 2020 8:26 pm

NAME New-SemanticVersion



SYNOPSIS

Creates a new semantic version.





SYNTAX

New-SemanticVersion [-Major <Int32>] [-Minor <Int32>] [-Patch <Int32>] [-PreRelease <Object>] [-Build <Object>]

[<CommonParameters>]



New-SemanticVersion [-InputObject] <Object[]> [<CommonParameters>]





DESCRIPTION

Creates a new object representing a semantic version number.





PARAMETERS

-Major <Int32>

The major version must be incremented if any backwards incompatible changes are introduced to the public API.



Required? false

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Minor <Int32>

The minor version must be incremented if new, backwards compatible functionality is introduced to the public

API.



Required? false

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Patch <Int32>

The patch version must be incremented if only backwards compatible bug fixes are introduced.



Required? false

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-PreRelease <Object>

A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility

requirements as denoted by its associated normal version.

The value can be a string or an array of strings. If an array of strings is provided, the elements of the array

will be joined using dot separators.



Required? false

Position? named

Default value @()

Accept pipeline input? false

Accept wildcard characters? false



-Build <Object>

The build metadata.

The value can be a string or an array of strings. If an array of strings is provided, the elements of the array

will be joined using dot separators.



Required? false

Position? named

Default value @()

Accept pipeline input? false

Accept wildcard characters? false



-InputObject <Object[]>

A valid semantic version string to be converted into a SemanticVersion object.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.Object



All Objects piped to this function are converted into Semantic Version objects.





OUTPUTS

PoshSemanticVersion





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>New-SemanticVersion -String '1.2.3-alpha.4+build.5'



Major : 1

Minor : 2

Patch : 3

PreRelease : alpha.4

Build : build.5



This command converts a valid Semantic Version string into a Semantic Version object. The output of the command

is a Semantic Version object with the elements of the version split into separate properties.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>New-SemanticVersion -Major 1 -Minor 2 -Patch 3 -PreRelease alpha.4 -Build build.5



Major : 1

Minor : 2

Patch : 3

PreRelease : alpha.4

Build : build.5



This command takes the Major, Minor, Patch, PreRelease, and Build parameters and produces the same output as the

previous example.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>New-SemanticVersion -Major 1 -Minor 2 -Patch 3 -PreRelease alpha, 4 -Build build, 5



Major : 1

Minor : 2

Patch : 3

PreRelease : alpha.4

Build : build.5



This command uses arrays for the PreRelease and Build parameters, but produces the same output as the

previous example.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>$semver = New-SemanticVersion -Major 1 -Minor 2 -Patch 3 -PreRelease alpha.4 -Build build.5



$semver.ToString()



1.2.3-alpha.4+build.5



This example shows that the object output from the previous command can be saved to a variable. Then by

calling the object's ToString() method, a valid Semantic Version string is returned.











RELATED LINKS