PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
475 stars 90 forks source link

Error parsing version from package name for filesystem-based repository #1641

Open sdwheeler opened 2 months ago

sdwheeler commented 2 months ago

Prerequisites

Steps to reproduce

PS> Get-PSResourceRepository -Name LocalPSResource

Name            Uri                        Trusted Priority
----            ---                        ------- --------
LocalPSResource file:///D:/LocalPSResource True    100

PS> Find-PSResource -Name Documentarian -Repository LocalPSResource -Debug -Verbose
DEBUG: In FindPSResource::ProcessResourceNameParameterSet()
DEBUG: Filtering package name(s) on wildcards
DEBUG: In FindHelper::FindByResourceName()
DEBUG: Parameters passed in >>> Name: 'Documentarian'; ResourceType: 'None'; VersionRange: ''; NuGetVersion: ''; VersionType: 'NoVersion'; Version: ''; Prerelease: 'False'; Tag: ''; Repository: 'LocalPSResource'; IncludeDependencies 'False'
DEBUG: Searching through repository 'LocalPSResource'
DEBUG: In FindHelper::SearchByNames()
DEBUG: No version specified, package name is specified
DEBUG: In LocalServerApiCalls::FindName()
DEBUG: In LocalServerApiCalls::FindNameHelper()
DEBUG: In LocalServerApiCalls::GetInfoFromFileName()
DEBUG: Version parsed as '0.0.1'
DEBUG: In LocalServerApiCalls::GetInfoFromFileName()
DEBUG: Version parsed as '0.0.2'
DEBUG: In LocalServerApiCalls::GetInfoFromFileName()
DEBUG: Version parsed as ''
Find-PSResource: Could not parse version devx.0.0.1 from file Documentarian.DevX.0.0.1.nupkg

PS> dir D:\LocalPSResource\

    Directory: D:\LocalPSResource

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           3/12/2024 10:49 AM          25126 Documentarian.0.0.1.nupkg
-a---           4/22/2024  3:41 PM          25358 Documentarian.0.0.2.nupkg
-a---           3/12/2024 10:49 AM          37419 Documentarian.DevX.0.0.1.nupkg
-a---           3/12/2024 10:49 AM          30318 Documentarian.MarkdownBuilder.0.0.1.nupkg
-a---           3/12/2024 10:49 AM          13310 Documentarian.MicrosoftDocs.0.0.2.nupkg
-a---           3/12/2024 10:49 AM          60297 Documentarian.ModuleAuthor.0.0.2.nupkg
-a---           3/12/2024 10:49 AM          24868 Documentarian.Vale.0.2.0.nupkg
-a---           7/27/2022  8:38 PM          10530 DocumentWMI.0.1.0-beta1.nupkg
-a---            4/2/2024  8:33 AM          13673 JDHTools.1.0.0.nupkg
-a---            8/9/2023  7:56 PM           5541 ManageIssues.1.0.2.nupkg
-a---           7/27/2022  6:59 PM          79342 Microsoft.PowerShell.WhatsNew.0.4.0.nupkg
-a---           9/15/2023  1:40 PM         181572 platyps.0.14.2.nupkg
-a---           9/15/2023  1:43 PM          19383 psini.3.1.3.nupkg
-a---          12/15/2023 12:46 PM           8308 PSStyle.1.1.7.nupkg
-a---           4/16/2024  9:43 PM           4951 sdwheeler.ADUtils.1.0.0.nupkg
-a---            2/5/2024  8:57 AM           7030 sdwheeler.ContentUtils.1.0.0.nupkg
-a---           4/16/2024  9:43 PM           7150 sdwheeler.ContentUtils.1.0.1.nupkg
-a---           4/16/2024  9:43 PM           3637 sdwheeler.CryptoTools.1.0.0.nupkg
-a---           3/19/2024 10:09 AM           3475 sdwheeler.DataConversion.1.0.1.nupkg
-a---           4/16/2024  9:43 PM           3119 sdwheeler.DataConversion.1.0.2.nupkg
-a---           7/28/2022  8:34 AM          13721 sdwheeler.DocsHelpers.1.0.5.nupkg
-a---           4/16/2024  9:43 PM           9787 sdwheeler.EssentialUtils.1.0.3.nupkg
-a---           4/16/2024  9:43 PM           5956 sdwheeler.FileManagement.1.0.2.nupkg
-a---           4/16/2024  9:43 PM          13107 sdwheeler.GitTools.1.1.2.nupkg
-a---           4/15/2024 10:16 AM           7755 sdwheeler.PSUtils.1.0.2.nupkg
-a---           4/16/2024  9:43 PM           7915 sdwheeler.PSUtils.1.0.3.nupkg
-a---           4/16/2024  9:43 PM           5559 sdwheeler.ROBTools.1.0.0.nupkg
-a---           4/16/2024  9:43 PM           3900 sdwheeler.SqliteTools.1.0.0.nupkg
-a---           4/16/2024  9:43 PM           5389 sdwheeler.SystemUtils.1.0.0.nupkg
-a---           4/16/2024  9:44 PM           5829 sdwheeler.Themes.0.0.1.nupkg
-a---           9/18/2023  2:26 PM         205104 Yayaml.0.1.1.nupkg

Expected behavior

Name          Version Prerelease Repository      Description
----          ------- ---------- ----------      -----------
Documentarian 0.0.2              LocalPSResource Collection of general purpose functions for working with Markdown doc…

Actual behavior

I get the error:

Find-PSResource: Could not parse version devx.0.0.1 from file Documentarian.DevX.0.0.1.nupkg

Error details

No response

Environment data

PS> gmo Microsoft.PowerShell.PSResourceGet

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     1.0.2                 Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PS…

PS> $PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      5      0      preview.2

Visuals

No response

sdwheeler commented 2 months ago

The problem seems to be caused by the fact that I have a module named Documentarian and several modules named Documentarian.<submodule>. The command works if I remove all of the Documentarian.<submodule> modules.

sdwheeler commented 2 months ago

This problem doesn't happen with PSGallery.

PS> Find-PSResource -Name Documentarian.* -Repository psgallery

Name                        Version Prerelease Repository Description
----                        ------- ---------- ---------- -----------
Documentarian.Vale          0.2.0              PSGallery  Collection of tools for installing and using the Vale prose …
Documentarian.ModuleAuthor  0.0.1              PSGallery  Collection of tools for creating and documenting PowerShell …
Documentarian.MicrosoftDocs 0.0.1              PSGallery  Collection of tools for working with Microsoft Docs content.
Documentarian               0.0.1              PSGallery  Collection of general purpose functions for working with Mar…

Find also works with wildcards. However, I can't use wildcards to install the module.

PS> Find-PSResource -Name Documentarian.* -Repository LocalPSResource

Name                          Version Prerelease Repository      Description
----                          ------- ---------- ----------      -----------
Documentarian.MarkdownBuilder 0.0.1              LocalPSResource Functions for interacting with a specialized string b…
Documentarian.ModuleAuthor    0.0.2              LocalPSResource Collection of tools for creating and documenting Powe…
Documentarian.DevX            0.0.1              LocalPSResource Collection of tools for building PowerShell modules a…
Documentarian.MicrosoftDocs   0.0.2              LocalPSResource Collection of tools for working with Microsoft Docs c…
Documentarian                 0.0.2              LocalPSResource Collection of general purpose functions for working w…
Documentarian.Vale            0.2.0              LocalPSResource Collection of tools for installing and using the Vale…