PowerShell / PowerShell/PSResourceGet
`Install-PSResource -Version` does not install the latest version of a module in given NuGet version range
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 576
- Fork
- 114
- Merge medio
- 1g 2h
- PR unite (30g)
- 7
Descrizione
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
According to the module doc, Install-PSResource command should install the latest version in given NuGet version range. However the command does not select the latest minor / patch version correctly. In below examples Install-PSResource installs version 2.9.1 although the latest version in given range is 2.25.0.
Here's the output of Find-PSResource that shows all the available versions of the example module at the time of writing.
PS> Find-PSResource Microsoft.Graph.Authentication -Repository PSGallery -Version '[2, 3)'
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
Microsoft.Graph.Authentication 2.9.1 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.9.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.8.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.6.1 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.5.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.4.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.3.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.25.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.24.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.23.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.22.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.21.1 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.21.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.20.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.2.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.19.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.18.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.17.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.16.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.15.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.14.1 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.14.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.13.1 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.13.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.12.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.11.1 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.11.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.10.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.1.0 PSGallery Microsoft Graph PowerShell Authentication Module.
Microsoft.Graph.Authentication 2.0.0 PSGallery Microsoft Graph PowerShell Authentication Module.
PowerShell Gallery link: Microsoft.Graph.Authentication
Expected behavior
PS> Install-PSResource -Name Microsoft.Graph.Authentication -Version '[2, 3)' -Repository PSGallery -PassThru | Select Name, Version
Name Version
---- -------
Microsoft.Graph.Authentication 2.25.0
Actual behavior
PS> Install-PSResource -Name Microsoft.Graph.Authentication -Version '[2, 3)' -Repository PSGallery -PassThru | Select Name, Version
Name Version
---- -------
Microsoft.Graph.Authentication 2.9.1
Error details
Environment data
PS> Get-Module Microsoft.PowerShell.PSResourceGet; $PSVersionTable | Format-Table
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 1.1.0 Microsoft.PowerShell.PSResourceGet {Compress-PSResource, Find-PSResource, Get-Insta…
Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Darwin 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 18:56:34 PST 2024; root:xnu-112…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
It appears that Install-PSResource simply installs the first module returned by the PowerShell Gallery API which does not always match the latest version.
PS> Install-PSResource -Name Microsoft.Graph.Authentication -Version '[2, 3)' -Repository PSGallery -Debug
<REDACTED>
DEBUG: In InstallPSResource::ProcessInstallHelper()
DEBUG: In InstallHelper::BeginInstallPackages()
DEBUG: Parameters passed in >>> Name: 'Microsoft.Graph.Authentication'; VersionRange: '[2, 3)'; NuGetVersion: ''; VersionType: 'VersionRange'; Version: '[2, 3)'; Prerelease: 'False'; Repository: 'PSGallery'; AcceptLicense: 'False'; Quiet: 'False'; Reinstall: 'False'; TrustRepository: 'False'; NoClobber: 'False'; AsNupkg: 'False'; IncludeXml 'True'; SavePackage 'False'; TemporaryPath ''; SkipDependencyCheck: 'False'; AuthenticodeCheck: 'False'; PathsToInstallPkg: '/Users/rasmusb/.local/share/powershell/Modules,/Users/rasmusb/.local/share/powershell/Scripts'; Scope 'CurrentUser'
DEBUG: In InstallHelper::ProcessRepositories()
VERBOSE: Attempting to search for packages in 'PSGallery'
DEBUG: In InstallHelper::InstallPackages()
DEBUG: In InstallHelper::InstallPackage()
DEBUG: In V2ServerAPICalls::FindVersionGlobbing()
DEBUG: In V2ServerAPICalls::FindVersionGlobbing()
DEBUG: In V2ServerAPICalls::HttpRequestCall()
DEBUG: Request url is 'https://www.powershellgallery.com/api/v2/FindPackagesById()?$filter=NormalizedVersion+ge+%272.0.0%27+and+NormalizedVersion+lt+%273.0.0%27+and+IsPrerelease+eq+false+and+Id+eq+%27Microsoft.Graph.Authentication%27&$inlinecount=allpages&$skip=0&$orderby=NormalizedVersion+desc&id=%27Microsoft.Graph.Authentication%27'
DEBUG: In V2ServerAPICalls::InstallVersion()
DEBUG: In V2ServerAPICalls::HttpRequestCallForContent()
DEBUG: Request url is 'https://www.powershellgallery.com/api/v2/package/Microsoft.Graph.Authentication/2.9.1'
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal punto di ingresso di Install-PSResource e segui i percorsi V2ServerAPICalls::FindVersionGlobbing e InstallVersion mostrati nell’output di debug. Riproduci il comando con l’intervallo '[2, 3)' e verifica come vengono selezionati i risultati in ordine decrescente. Il lavoro è completato quando il comando installa la versione 2.25.0, la versione più recente nell’intervallo, invece di 2.9.1.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp, powershell
- Ambito
- cli, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100