OneGet / oneget

PackageManagement (aka OneGet) is a package manager for Windows
MIT License
2.38k stars 190 forks source link

Cannot install package using pre-release semvers #159

Closed heaths closed 8 years ago

heaths commented 8 years ago

If using semver and you have a pre-release like 3.0.0-pre, you cannot install that package becase the version can't be parsed into System.Version:

PS> install-package msi -allversions -scope currentUser -requiredversion 3.0.0-pre0013
install-package : Cannot convert value "3.0.0-pre0013" to type "System.Version". Error: "Input string was not in a correct format."
At line:1 char:1
+ install-package msi -allversions -scope currentUser -requiredversion  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : InvalidCastParseTargetInvocation,New-PSGetItemInfo,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Perhaps semvers aren't supported, but https://powershellgallery.com does make reference to it on the module page (see related bug).

heaths commented 8 years ago

FWIW, I tested the following and neither works with get-module (i.e. PowerShell's built-in cmdlet):

So with that in mind, maybe this issue is not worth fixing. Might also consider a specific message that it's not currently supported.

Jaykul commented 8 years ago

PowerShell modules don't support semver, but NuGet does, and there are plenty of other repositories...

heaths commented 8 years ago

@Jaykul, what do you mean? I realize that NuGet does (which is why I was building my modules that way), but not sure how that relates to PSGet. PSGet is built on NuGet, yes, but it's specifically for obtaining PowerShell modules so if PS doesn't support it, PSGet probably shouldn't allow I. Hence the request to maybe block upload attempts server-side when modules would be incompatible. As it is, I had to log in and hide a bunch of versions that got uploaded through build/publish automation.

Jaykul commented 8 years ago

My point is, Install-Package is not (only) for installing PowerShell modules.

Install-Package is the generic install command from OneGet (the PackageManagement module). In addition to PowerShell modules, you can use it to install NuGet libraries (I do this all the time), chocolatey apps (both of which support SemVer) and more.

I agree that the PowerShell Gallery should prevent modules with invalid versions from being uploaded (actually, I'd prefer if PowerShell supported SemVer, but that seems unlikely), but that's their problem (PowerShell's) and therefore must be fixed in PowerShellGallery, and PowerShellGet.

It can't be fixed in the generic OneGet PackageManagement module.

heaths commented 8 years ago

Understood, but without a better place to files bugs against PSGet (which is where this can and should be fixed until the PowerShell team supports it, which I started a thread on internally) I filed it here.

jianyunt commented 8 years ago

Because PowerShell supports .Net Version only, there is no plan to support semver in PowerShellGet.