JustinGrote / ModuleFast

A "fast and loose" way to install modules from Powershell Gallery quickly. Meant for CICD, not production
Other
77 stars 5 forks source link

`Get-ModuleFastPlan`: Does not recognize preview versions are already available #21

Closed johlju closed 8 months ago

johlju commented 8 months ago

When expected versions are already installed Get-ModuleFast normally does not return those as missing. But for preview versions it always returns them as missing even though they are in fact installed. Below shows the difference where two modules are installed and only the preview one is always listed as missing/needed.

PS> Get-Module -Name 'Plaster', 'WebAdministrationDsc' -ListAvailable | Format-Table Name, Version, @{Name='Prerelease'; Expression={$_.PrivateData.PSData.Prerelease}}

Name                 Version Prerelease
----                 ------- ----------
Plaster              1.1.4
WebAdministrationDsc 4.1.1   preview0001

PS> 'Plaster', 'WebAdministrationDsc@4.1.1-preview0001' | Get-ModuleFastPlan

Name                 ModuleVersion
----                 -------------
WebAdministrationDsc 4.1.1-preview0001
JustinGrote commented 8 months ago

Please try with Install-ModuleFast -WhatIf and see if it still occurs.

JustinGrote commented 8 months ago

Nevermind, there is a bug here. Note that -verbose and -debug have a lot of info.

DEBUG: webadministrationdsc [4.1.1-preview0001, 4.1.1-preview0001]: Found satisfying version 4.1.1-preview0001 in the additional pages.
VERBOSE: WebAdministrationDsc@4.1.1-preview0001: Added to install plan  

If it found a satisfying version it shouldn't have been added to the plan. I'll investigate.

JustinGrote commented 8 months ago

Looks like the local match logic isn't working for prerelease, I might still have a basic version cast in there somewhere, or this step is just using the modulefolder version as a fast assumption and not checking the manifest for prerelease: DEBUG: webadministrationdsc: Found a module C:\Users\JGrote\AppData\Local\powershell\Modules\WebAdministrationDsc\4.1.1\WebAdministrationDsc.psd1 that matches the name but does not satisfy the version spec webadministrationdsc [4.1.1-preview0001, 4.1.1-preview0001]. Skipping...

JustinGrote commented 8 months ago

Should be fixed by https://github.com/JustinGrote/ModuleFast/pull/30

And Test Covered by: https://github.com/JustinGrote/ModuleFast/blob/dc352e3d3720ca8a16205dd21c5abcee83965387/ModuleFast.tests.ps1#L509