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

オープン
#1,751 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp, powershell
領域
cli, tooling

調査の方向性

まず、Install-PSResource に示されているコマンドと、対応する Save-PSResource のケースを再現し、その後パラメーター検証を追跡します。複数の -Name 値を -Version とともに指定すると記載されたエラーが発生し、単一の -Name 値では引き続き動作するようになれば、変更は完了です。既存のコマンドテストが配置されている場所で、カバレッジを追加または更新してください。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
C#
スター
581
フォーク
116
平均マージ
1日 21時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PowerShell/PSResourceGet のほかの issue

PowerShell/PSResourceGet の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。