diff --git a/Plaster/Private/Initialize-SemanticVersion.ps1 b/Plaster/Private/Initialize-SemanticVersion.ps1 new file mode 100644 index 0000000..c1777a6 --- /dev/null +++ b/Plaster/Private/Initialize-SemanticVersion.ps1 @@ -0,0 +1,20 @@ +if (-not ([System.Management.Automation.PSTypeName]'System.Management.Automation.SemanticVersion').Type) { + Add-Type -TypeDefinition @' +namespace System.Management.Automation { + public class SemanticVersion { + public int Major { get; private set; } + public int Minor { get; private set; } + public int Patch { get; private set; } + public SemanticVersion(string version) { + var parts = version.Split('.'); + Major = int.Parse(parts[0]); + Minor = parts.Length > 1 ? int.Parse(parts[1]) : 0; + Patch = parts.Length > 2 ? int.Parse(parts[2]) : 0; + } + public override string ToString() { + return Major + "." + Minor + "." + Patch; + } + } +} +'@ +} diff --git a/Plaster/Private/Resolve-ModuleVersionString.ps1 b/Plaster/Private/Resolve-ModuleVersionString.ps1 index f451aad..b195e51 100644 --- a/Plaster/Private/Resolve-ModuleVersionString.ps1 +++ b/Plaster/Private/Resolve-ModuleVersionString.ps1 @@ -36,17 +36,9 @@ function Resolve-ModuleVersionString { $VersionString = "$VersionString.0" } - if ($PSVersionTable.PSEdition -eq "Core") { - $newObjectSplat = @{ - TypeName = "System.Management.Automation.SemanticVersion" - ArgumentList = $VersionString - } - return New-Object @newObjectSplat - } else { - $newObjectSplat = @{ - TypeName = "System.Version" - ArgumentList = $VersionString - } - return New-Object @newObjectSplat + $newObjectSplat = @{ + TypeName = "System.Management.Automation.SemanticVersion" + ArgumentList = $VersionString } + return New-Object @newObjectSplat }