JustinGrote / ModuleFast

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

`Install-ModuleFast -Destination` won't install modules if ModuleFast detects the same module installed some other place on the system #45

Closed o-l-a-v closed 7 months ago

o-l-a-v commented 7 months ago

I expect the -Destination parameter in Install-ModuleFast to don't care about modules installed elsewhere. This is a breaking change with rc1 vs. earlier versions, I think.

Either change the default behavior, or add a parameter -IgnoreExistingModules or something like that.

Reproduce

Prerequirement

Input

$ModulePath = [string] '{0}\Modules' -f $env:TEMP
if (-not [System.IO.Directory]::Exists($ModulePath)) {
    $null = [System.IO.Directory]::CreateDirectory($ModulePath)
}
$env:MFRELEASE='v0.1.0-rc1';iwr bit.ly/modulefastmain | iex
Install-ModuleFast -NoPSModulePathUpdate -NoProfileUpdate -Update -Destination $ModulePath -ModulesToInstall (
    'Az.Accounts',
    'Az.Compute',
    'Az.Resources',
    'Az.ResourceGraph',
    'Az.StreamAnalytics'
)

Output

PS C:\Users\olav.birkeland> Install-ModuleFast -NoPSModulePathUpdate -NoProfileUpdate -Update -Destination $ModulePath -ModulesToInstall (
>>     'Az.Accounts',
>>     'Az.Compute',
>>     'Az.Resources',
>>     'Az.ResourceGraph',
>>     'Az.StreamAnalytics','Microsoft.Graph.Authentication'
>> ) -Verbose
VERBOSE: Az.Accounts: Evaluating Module Specification
VERBOSE: Az.Compute: Evaluating Module Specification
VERBOSE: Az.Resources: Evaluating Module Specification
VERBOSE: Az.ResourceGraph: Evaluating Module Specification
VERBOSE: Az.StreamAnalytics: Evaluating Module Specification
VERBOSE: Microsoft.Graph.Authentication: Evaluating Module Specification
VERBOSE: ✅ 6 Module Specifications have all been satisfied by installed modules. If you would like to check for newer versions remotely, specify -Update
PS
JustinGrote commented 7 months ago

Thanks @o-l-a-v! I will note this in the breaking changes section. Note if you want the latest versions of modules, that's what -Update is for, it ignores existing modules for purposes of dependency resolution.

For only considering the destination folder for evaluation, I will add a -DestinationOnly parameter that will disregard other potential module folders in the psmodulepath.