PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
495 stars 93 forks source link

Add 'ToLower' before name comparison and split #1738

Closed alerickson closed 4 weeks ago

alerickson commented 1 month ago

PR Summary

When installing from a local repositories, the comparison done to split a full nupkg name (eg. 'Microsoft.PowerShell.PSResourceGet.1.1.0-RC1.nupkg') into both name ('Microsoft.PowerShell.PSResourceGet') and version+extension ('1.1.0-RC1.nupkg') needs to be case insensitive.

The .nupkg name typically all lowercase, whereas the version for a package may contain some uppercase characters that cause the split comparison to fail.

This PR adds .ToLower() to both the full package name and to the 'package version and extension' in order to ensure case insensitivity all round.

Note: this bug was reproducible when attempting to find or install "Microsoft.PowerShell.PSResourceGet" v1.1.0-RC1 from a local repository. Bug was caught through CI failure.


Second bug was uncovered when running tests for this PR. When Find-PSResource would return packages found in a local repository it was not returning the correct casing for the package name. This also impacted Install because the object returned from Find is then used to create file names for installation. Incorrect casing was causing failures on Linux machines.
The fix for this is to parse out the correct package name casing when retrieving metadata for a package so that the object that is either returned or passed on to Install has the correct package name.

Note: this bug was reproducible when attempting to install a package from a local repository with the incorrect casing for the name. For example, attempting to install clobberTestMOdule2 from a local repository (correct name is ClobberTestModule2-- this package can be found on the PSGallery).

PR Context

PR Checklist