PowerShell / PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
https://www.PowerShellGallery.com
MIT License
432 stars 138 forks source link

Install-Package fails on package with only prerelease versions #695

Open robunoki-microsoft opened 1 year ago

robunoki-microsoft commented 1 year ago

Prerequisites

Steps to reproduce

D:\ Find-Package Azure.Communication.Email -Source nuget.org -AllowPrereleaseVersions -AllVersions

Name                           Version          Source           Summary
----                           -------          ------           -------
Azure.Communication.Email      1.0.0-beta.2     nuget.org        This client library enables working with the Microsoft Azure Communication Ema…
Azure.Communication.Email      1.0.0-beta.1     nuget.org        This client library enables working with the Microsoft Azure Communication Ema…

D:\ Install-Package  -AllowPrereleaseVersions -Name "Azure.Communication.Email"
Install-Package: No match was found for the specified search criteria and package name 'Azure.Communication.Email'. Try Get-PackageSource to see all available registered package sources.

D:\ Install-Package  -AllowPrereleaseVersions -Name Azure.Communication.Email
Install-Package: No match was found for the specified search criteria and package name 'Azure.Communication.Email'. Try Get-PackageSource to see all available registered package sources.

D:\ Install-Package  -AllowPrereleaseVersions -AllVersions -Name Azure.Communication.Email
WARNING: 'Azure.Communication.Email' matched package 'Azure.Communication.Email/1.0.0-beta.2' from provider: 'NuGet', source 'nuget.org'.
WARNING: 'Azure.Communication.Email' matched package 'Azure.Communication.Email/1.0.0-beta.1' from provider: 'NuGet', source 'nuget.org'.
Install-Package: Unable to install, multiple packages matched 'Azure.Communication.Email'. Please specify an exact -Name and -RequiredVersion.

D:\ Install-Package  -AllowPrereleaseVersions -AllVersions -Name Azure.Communication.Email -RequiredVersion "1.0.0-beta.2"
Install-Package: No match was found for the specified search criteria and package name 'Azure.Communication.Email'. Try Get-PackageSource to see all available registered package sources.```

### Expected behavior

```console
One of the Install-Package commands above should succeed.

Actual behavior

All of the Install-Package commands fail.

Error details

D:\ Find-Package Azure.Communication.Email -Source nuget.org -AllowPrereleaseVersions -AllVersions

Name                           Version          Source           Summary
----                           -------          ------           -------
Azure.Communication.Email      1.0.0-beta.2     nuget.org        This client library enables working with the Microsoft Azure Communication Ema…
Azure.Communication.Email      1.0.0-beta.1     nuget.org        This client library enables working with the Microsoft Azure Communication Ema…

D:\ Install-Package  -AllowPrereleaseVersions -Name "Azure.Communication.Email"
Install-Package: No match was found for the specified search criteria and package name 'Azure.Communication.Email'. Try Get-PackageSource to see all available registered package sources.

D:\ Install-Package  -AllowPrereleaseVersions -Name Azure.Communication.Email
Install-Package: No match was found for the specified search criteria and package name 'Azure.Communication.Email'. Try Get-PackageSource to see all available registered package sources.

D:\ Install-Package  -AllowPrereleaseVersions -AllVersions -Name Azure.Communication.Email
WARNING: 'Azure.Communication.Email' matched package 'Azure.Communication.Email/1.0.0-beta.2' from provider: 'NuGet', source 'nuget.org'.
WARNING: 'Azure.Communication.Email' matched package 'Azure.Communication.Email/1.0.0-beta.1' from provider: 'NuGet', source 'nuget.org'.
Install-Package: Unable to install, multiple packages matched 'Azure.Communication.Email'. Please specify an exact -Name and -RequiredVersion.

D:\ Install-Package  -AllowPrereleaseVersions -AllVersions -Name Azure.Communication.Email -RequiredVersion "1.0.0-beta.2"
Install-Package: No match was found for the specified search criteria and package name 'Azure.Communication.Email'. Try Get-PackageSource to see all available registered package sources.

Environment data

D:\ $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.3
PSEdition                      Core
GitCommitId                    7.3.3
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

D:\ Get-PackageSource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
nuget.org                        NuGet            True       https://api.nuget.org/v3/index.json
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2

D:\ Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrerelease…
PowerShellGet            2.2.5.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate…

Version

7.3.3

Visuals

No response

LaurentDardenne commented 6 months ago

The version number '1.0.0-beta.2' is a valid semver 2.0 but an invalid powshellget version. From : https://learn.microsoft.com/en-us/powershell/gallery/concepts/module-prerelease-support?view=powershellget-2.x

Only SemVer v1.0.0 prerelease strings are supported at this time. Prerelease string must not contain either period or + [.+], which are allowed in SemVer 2.0.

https://github.com/PowerShell/PowerShellGetv2/blob/master/src/PowerShellGet/private/functions/ValidateAndGet-VersionPrereleaseStrings.ps1#L36