Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Plaster/Private/Initialize-SemanticVersion.ps1
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
'@
}
16 changes: 4 additions & 12 deletions Plaster/Private/Resolve-ModuleVersionString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading