Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

`Install-PSResource -Version` does not install the latest version of a module in given NuGet version range

Abierto
#1,776 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
csharp, powershell
Área
cli, tooling

Línea de trabajo

Comienza en el punto de entrada de Install-PSResource y sigue las rutas V2ServerAPICalls::FindVersionGlobbing y InstallVersion que se muestran en la salida de depuración. Reproduce el comando con el rango '[2, 3)' e inspecciona cómo se seleccionan los resultados en orden descendente. Se considera terminado cuando el comando instala la versión 2.25.0, la versión más reciente del rango, en lugar de 2.9.1.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Issue-Bug
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'
Lenguaje dominante
C#
Estrellas
577
Forks
114
Merge medio
23 h 17 min
PR fusionados (30 d)
8

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PowerShell/PSResourceGet

Todos los issues de PowerShell/PSResourceGet

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.