@@ -478,7 +478,7 @@ function Install-ModuleFastHelper {
478478
479479 # Installation jobs are captured here, we will check them once all downloads have completed
480480 [List [Job2 ]]$installJobs = @ ()
481-
481+ # TODO: Filestreams should be disposed in a try/catch in case of cancellation. In PS 7.3+, should be a clean() block
482482 while ($downloadTasks.count -gt 0 ) {
483483 # TODO: Check on in jobs and if there's a failure, cancel the rest of the jobs
484484 $noTasksYetCompleted = -1
@@ -535,10 +535,10 @@ function Install-ModuleFastOperation {
535535 [string ]$Destination
536536 )
537537 $ErrorActionPreference = ' Stop'
538- Write-Host " Installing $Name $Version from $DownloadPath to $Destination "
539- $Destination = Join-Path $Destination $Name $Version
540- Expand-Archive - Path $DownloadPath - DestinationPath $Destination - Force
541- Write-Host " Installed $Name $Version from $DownloadPath to $Destination "
538+ $ModuleDestination = Join-Path $Destination $Name $Version
539+ Write-Host " Installing $Name $Version from $DownloadPath to $ModuleDestination "
540+ Expand-Archive - Path $DownloadPath - DestinationPath $ModuleDestination - Force
541+ Write-Host " Installed $Name $Version from $DownloadPath to $ModuleDestination "
542542}
543543
544544# region Classes
@@ -582,10 +582,10 @@ class ModuleFastSpec : IComparable {
582582 }
583583 }
584584
585- # ModuleSpecification Compatible Aliases
586- hidden [SemanticVersion ]Get_RequiredVersion() { return [ModuleFastSpec ]::ParseSemanticVersion($this.Required ) }
587- hidden [SemanticVersion ]Get_Version() { return [ModuleFastSpec ]::ParseSemanticVersion($this.Min ) }
588- hidden [SemanticVersion ]Get_MaximumVersion() { return [ModuleFastSpec ]::ParseSemanticVersion($this.Max ) }
585+ # ModuleSpecification Compatible Getters
586+ hidden [Version ]Get_RequiredVersion() { return [ModuleFastSpec ]::ParseSemanticVersion($this.Required ) }
587+ hidden [Version ]Get_Version() { return [ModuleFastSpec ]::ParseSemanticVersion($this.Min ) }
588+ hidden [Version ]Get_MaximumVersion() { return [ModuleFastSpec ]::ParseSemanticVersion($this.Max ) }
589589
590590 # Constructors
591591
@@ -665,20 +665,20 @@ class ModuleFastSpec : IComparable {
665665
666666 # ## Version Helper Methods
667667 # Determines if a version is within range of the spec.
668- [bool ] Matches ([SemanticVersion ]$Version ) {
668+ [bool ] Matches([SemanticVersion ]$Version ) {
669669 if ($null -eq $Version ) { return $false }
670670 if ($Version -ge $this.Min -and $Version -le $this.Max ) { return $true }
671671 return $false
672672 }
673- [bool ] Matches ([Version ]$Version ) {
673+ [bool ] Matches([Version ]$Version ) {
674674 return $this.Matches ([ModuleFastSpec ]::ParseVersion($Version ))
675675 }
676- [bool ] Matches ([String ]$Version ) {
676+ [bool ] Matches([String ]$Version ) {
677677 return $this.Matches ([ModuleFastSpec ]::ParseVersionString($Version ))
678678 }
679679
680680 # Determines if this spec is at least partially inside of the supplied spec
681- [bool ] Overlaps ([ModuleFastSpec ]$Spec ) {
681+ [bool ] Overlaps([ModuleFastSpec ]$Spec ) {
682682 if ($null -eq $Spec ) { return $false }
683683 if ($Spec.Name -ne $this.Name ) { throw " Supplied Spec Name $ ( $Spec.Name ) does not match this spec name $ ( $this.Name ) " }
684684 if ($Spec.Guid -ne $this.Guid ) { throw " Supplied Spec Guid $ ( $Spec.Name ) does not match this spec guid $ ( $this.Name ) " }
@@ -691,17 +691,17 @@ class ModuleFastSpec : IComparable {
691691 # Parses either a assembly version or semver to a semver string
692692 static [SemanticVersion ] ParseVersionString([string ]$Version ) {
693693 if (-not $Version ) { throw [NotSupportedException ]' Null or empty strings are not supported' }
694- $result = $Version -match [ ModuleFastSpec ]::SYSTEM_VERSION_REGEX `
695- ? [ SemanticVersion ]::ParseVersion([ Version ] $Version )
696- : [ SemanticVersion ] $Version
697- return $result
694+ if ( $Version -as [ Version ]) {
695+ return [ ModuleFastSpec ]::ParseVersion($Version )
696+ }
697+ return $Version
698698 }
699699
700700 # A version number with 4 octets wont cast to semanticversion properly, this is a helper method for that.
701701 # We treat "revision" as "build" and "build" as patch for purposes of translation
702702 # Needed because SemVer can't parse builds correctly
703703 # https://github.com/PowerShell/PowerShell/issues/14605
704- static [SemanticVersion ]ParseVersion([Version ]$Version ) {
704+ static [SemanticVersion ] ParseVersion([Version ]$Version ) {
705705 if (-not $Version ) { throw [NotSupportedException ]' Null or empty strings are not supported' }
706706
707707 [list [string ]]$buildLabels = @ ()
@@ -731,9 +731,14 @@ class ModuleFastSpec : IComparable {
731731 }
732732
733733 # A way to go back from SemanticVersion, the anticedent to ParseVersion
734- static [Version ]ParseSemanticVersion([SemanticVersion ]$Version ) {
734+ static [Version ] ParseSemanticVersion([SemanticVersion ]$Version ) {
735735 if ($null -eq $Version ) { throw [NotSupportedException ]' Null or empty strings are not supported' }
736736
737+ # If this only has a build "version" but no Prerelease tag, we can translate that to the revision
738+ if (-not $Version.PreReleaseLabel -and $Version.BuildLabel -and $Version.BuildLabel -as [int ]) {
739+ return [Version ]::new($Version.Major , $Version.Minor , $Version.Patch , $Version.BuildLabel )
740+ }
741+
737742 [string []]$buildFlags = $Version.BuildLabel -split ' \.'
738743 if ($BuildFlags -notcontains [ModuleFastSpec ]::SYSTEM_VERSION_LABEL) {
739744 # This is a semantic-compatible version, we can just return it
@@ -761,7 +766,7 @@ class ModuleFastSpec : IComparable {
761766
762767 # This string will be unique for each spec type, and can (probably)? Be safely used as a hashcode
763768 # TODO: Implement parsing of this string to the parser to allow it to be "reserialized" to a module spec
764- [string ]ToString() {
769+ [string ] ToString() {
765770 $name = $this._Name + ($this._Guid -ne [Guid ]::Empty ? " [$ ( $this._Guid ) ]" : ' ' )
766771 $versionString = switch ($true ) {
767772 ($this.Min -eq [ModuleFastSpec ]::MinVersion -and $this.Max -eq [ModuleFastSpec ]::MaxVersion) {
@@ -780,7 +785,7 @@ class ModuleFastSpec : IComparable {
780785 # We can however just add Equals() method
781786
782787 # Implementation of https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1.equals?view=net-6.0
783- [boolean ] Equals ([Object ]$obj ) {
788+ [boolean ] Equals([Object ]$obj ) {
784789 if ($null -eq $obj ) { return $false }
785790 switch ($obj.GetType ()) {
786791 # Comparing ModuleSpecs means that we want to ensure they are structurally the same
0 commit comments