RamblingCookieMonster / PSDepend

PowerShell Dependency Handler
MIT License
277 stars 75 forks source link

Updating a module that is not using semantic version fails #118

Open johlju opened 4 years ago

johlju commented 4 years ago

I have a module dependency of PSPKI which has a version of 3.5. When using PSDepend to verify this module is the current one it fails with the below error. This recently started when PSDepend was updated to a newer version.

PSGalleryModule.ps1: C:\source\SqlServerDsc\output\RequiredModules\PSDepend\0.3.7\Public\Invoke-DependencyScript.ps1:195                              Line |                                                                                                                                                 195 |                      $Output = . $DependencyScript @splat                                                                                           |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                           | Could not compare "3.5" to "3.5.0". Error: "Cannot convert the "3.5.0" value of type "System.Management.Automation.SemanticVersion"                 | to type "System.Double"."
sheldonhull commented 4 years ago

I also am getting this.

Running Install-PSDepend
ERROR: Could not compare "1" to "1.0.0". Error: "Cannot convert the "1.0.0" value of type "System.Management.Automation.SemanticVersion" to type "System.Double"."
At /Users/sheldonhull/.local/share/powershell/Modules/PSDepend/0.3.8/Public/Invoke-DependencyScript.ps1:195 char:31
+                     $Output = . $DependencyScript @splat
scottbilas commented 3 years ago

Also with the Native package:

InvalidOperation: C:\Users\scott\Documents\PowerShell\Modules\PSDepend\0.3.8\PSDependScripts\PSGalleryModule.ps1:269
Line |
 269 |          $GalleryVersion -le $parsedSemanticVersion
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Could not compare "1.5" to "1.5.0". Error: "Cannot convert the "1.5.0" value of type
     | "System.Management.Automation.SemanticVersion" to type "System.Double"."
scottbilas commented 3 years ago

I believe this is the fix

--- .\PSGalleryModule.0.ps1
+++ .\PSGalleryModule.ps1
@@ -266,7 +266,7 @@
         [System.Management.Automation.SemanticVersion]::TryParse($ExistingVersion, [ref]$parsedSemanticVersion) -and
         [System.Management.Automation.SemanticVersion]::TryParse($GalleryVersion, [ref]$parsedTempSemanticVersion)
     ) {
-        $GalleryVersion -le $parsedSemanticVersion
+        $parsedTempSemanticVersion -le $parsedSemanticVersion
     }
     elseif ([System.Version]::TryParse($ExistingVersion, [ref]$parsedVersion)) {
         $GalleryVersion -le $parsedVersion