`Find-PSResource` Does Not Properly Evaluate/Compare Available Package Versions Against Specified Version

未关闭
#1,782 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp, powershell
领域
cli, tooling

调研方向

从 Find-PSResource 入口点开始,在 PSResourceGet 模块上重现 issue 中显示的版本范围命令。将 [6, ] 和 [10, ] 的结果与预期可用版本进行比较;当从 6 开始的范围在报告的 PowerShell 环境中按正确的数值顺序包含所有更新版本时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Issue-Bug
Steps to reproduce
  1. Run a Find-PSResource cmdlet with -Version param specified that should show all versions from a specific version and above.
    Find-PSResource VMware.PowerCLI -Version "[6, ]"
  2. See that the output does not necessarily include all newer available versions (depending on the input version given).
Expected behavior

In this example scenario, the output should have produced lines for all versions of PowerCLI from v6.x up through v13.x which is the current. The old Find-Module cmdlet with -AllVersions param reflects this behavior:

PS > Find-Module -Name 'VMware.PowerCLI' -AllVersions

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
13.3.0.24145081      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.2.1.22851661      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.2.0.22746353      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.1.0.21624340      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
13.0.0.20829139      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.7.0.20091289      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.6.0.19610541      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.5.0.19195797      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.4.1.18769701      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.4.0.18633274      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.3.0.17860403      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.2.0.17538434      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.1.0.17009493      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
12.0.0.15947286      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.5.0.14912921      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.4.0.14413515      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.3.0.13990089      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.2.0.12780525      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.2.0.12483598      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.1.0.11289667      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
11.0.0.10380590      VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.2.0.9372002       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.1.1.8827524       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.1.0.8403314       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
10.0.0.7895300       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.4.7155375        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.3.6870460        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.2.6268016        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
6.5.1.5377412        VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...
Actual behavior

Instead we only see lines for the v6.x versions.

PS > Find-PSResource VMware.PowerCLI -Version "[6, ]"

Name            Version       Prerelease Repository Description
----            -------       ---------- ---------- -----------
VMware.PowerCLI 6.5.4.7155375            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 6.5.3.6870460            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 6.5.2.6268016            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 6.5.1.5377412            PSGallery  This Windows PowerShell module contains VMware.PowerCLI

We could run the same command again but with the value 10 inside the version string this time, instead of 6, to confirm that there are in fact newer versions available.

PS > Find-PSResource VMware.PowerCLI -Version "[10, ]"

Name            Version         Prerelease Repository Description
----            -------         ---------- ---------- -----------
VMware.PowerCLI 13.3.0.24145081            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.2.1.22851661            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.2.0.22746353            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.1.0.21624340            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 13.0.0.20829139            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.7.0.20091289            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.6.0.19610541            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.5.0.19195797            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.4.1.18769701            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.4.0.18633274            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.3.0.17860403            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.2.0.17538434            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.1.0.17009493            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 12.0.0.15947286            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.5.0.14912921            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.4.0.14413515            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.3.0.13990089            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.2.0.12780525            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.2.0.12483598            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.1.0.11289667            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 11.0.0.10380590            PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.2.0.9372002             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.1.1.8827524             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.1.0.8403314             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
VMware.PowerCLI 10.0.0.7895300             PSGallery  This Windows PowerShell module contains VMware.PowerCLI
Error details

I'm assuming this has something to do with it not properly interpreting or "sorting" the version field. It appears to be sorting in lexicographical order instead of numerical order (so it thinks 10.x is lower than 6.x since 10 starts with a 1) - that's just a guess based on the behavior I've seen but I could be wrong.

Also I would add that the behavior has been reproduced on both WindowsPowerShell (v5.1) as well as PowerShell (v7).

Please let me know if any additional info is needed.

Thanks!

Environment data
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.1.0      Microsoft.PowerShell.PSResourceGet  {Compress-PSResource, Find-PSResource, Get-InstalledPSReso...

Key   : PSVersion
Value : 5.1.19041.5369
Name  : PSVersion


Key   : PSEdition
Value : Desktop
Name  : PSEdition


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions


Key   : BuildVersion
Value : 10.0.19041.5369
Name  : BuildVersion


Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion
Visuals

Image

主要语言
C#
星标
576
派生
114
平均合并
23 小时 17 分钟
30 天内合并 PR
8

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PowerShell/PSResourceGet 的其他 Issue

查看 PowerShell/PSResourceGet 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。