Don't accept `-Version` if string array was supplied to `-Name` in `Install-PSResource` and `Save-PSResource`

Ouverte
#1,751 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
42/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
csharp, powershell
Domaine
cli, tooling

Piste de recherche

Commencez par reproduire les commandes indiquées pour Install-PSResource ainsi que le cas équivalent de Save-PSResource, puis suivez leur validation des paramètres. La modification est terminée lorsque la fourniture de plusieurs valeurs -Name avec -Version produit l’erreur indiquée, tandis qu’une seule valeur -Name continue de fonctionner ; ajoutez ou mettez à jour la couverture là où se trouvent les tests de commandes existants.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Issue-Discussion
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

With Microsoft.PowerShell.PSResourceGet v1.0.6 you can supply -Version when supplying multiple resources with -Name.

That does not make much sense and should error instead of event trying, in my opinion.

Example command:

Install-PSresource -Repository 'PSGallery' -TrustRepository -Scope 'CurrentUser' `
    -Name 'Az.Accounts', 'Microsoft.Graph.Authentication' -Version '3.0.5' -Verbose
Expected behavior
ERROR: -Version can only be supplied if -Name is a single value.
Actual behavior
PS > Install-PSresource -Repository 'PSGallery' -TrustRepository -Scope 'CurrentUser' -Name 'Az.Accounts', 'Microsoft.Graph.Authentication' -Version '3.0.5' -Verbose

VERBOSE: All paths to search: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules'
VERBOSE: All paths to search: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Scripts'
VERBOSE: Retrieving directories in the path 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules'
VERBOSE: Retrieving directories in the path 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Scripts'
VERBOSE: All paths to search: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure'
VERBOSE: The PSGetModuleInfo.xml file found at location: C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure\0.86.0.0\PSGetModuleInfo.xml cannot be parsed due to TryReadPSGetInfo: Cannot read the PSResourceGet information file with error: Could not find file 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure\0.86.0.0\PSGetModuleInfo.xml'.
VERBOSE: Attempting to search for packages in 'PSGallery'
VERBOSE: Performing the operation "Install-PSResource" on target "Package to install: 'Az.Accounts', version: '3.0.5'".
VERBOSE: Performing the operation "Install-PSResource" on target "Exit ShouldProcess".
VERBOSE: Installation source path is: 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4\az.accounts\3.0.5'
VERBOSE: Installation destination path is: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Az.Accounts\3.0.5'
VERBOSE: Attempting to move 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4\az.accounts\3.0.5' to 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Az.Accounts\3.0.5'
VERBOSE: Successfully installed package 'Az.Accounts' to location 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules'
VERBOSE: Attempting to delete 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4'
VERBOSE: Successfully deleted 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4'
VERBOSE: Package with name 'Microsoft.Graph.Authentication', version '3.0.5' could not be found in repository 'PSGallery'.
VERBOSE: Attempting to delete 'C:\Users\olav.birkeland\AppData\Local\Temp\3b2ac088-6a76-4541-85bb-0501bd87b2c1'
VERBOSE: Successfully deleted 'C:\Users\olav.birkeland\AppData\Local\Temp\3b2ac088-6a76-4541-85bb-0501bd87b2c1'
Install-PSResource: Package(s) 'Microsoft.Graph.Authentication' could not be installed from repository 'PSGallery'.

PS >
Error details

No response

Environment data
  • Windows 11 24H2
  • PowerShell x64 v7.4.6
  • Microsoft.PowerShell.PSResourceGet v1.0.6
Visuals

No response

Langage dominant
C#
Étoiles
581
Forks
116
Merge moyen
1 j 21 h
PR mergées (30 j)
9

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de PowerShell/PSResourceGet

Toutes les issues de PowerShell/PSResourceGet

Issues similaires

Plus d'issues C#

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.