JustinGrote / ModuleFast

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

Fails to write lockfile for multiple modules with different versions #96

Open picccard opened 6 days ago

picccard commented 6 days ago

error

My pipeline errors out:

...
2024-10-13T21:43:40.6358609Z VERBOSE: Az.Accounts(3.0.2): Added to install plan
...
2024-10-13T21:43:41.1731039Z VERBOSE: Az.Accounts(3.0.4): Added to install plan
...
2024-10-13T21:43:45.2143307Z VERBOSE: ✅ All required modules installed! Exiting.
2024-10-13T21:43:45.2183731Z 
2024-10-13T21:43:45.2208006Z VERBOSE: Writing lockfile to /home/runner/work/miscellaneous/miscellaneous/requires.lock.json
2024-10-13T21:43:45.2770822Z Install-ModuleFast : Exception calling "Add" with "2" argument(s): "An item with the same key has already been added. Key: Az.Accounts"
2024-10-13T21:43:45.2773238Z At /home/runner/work/_actions/JustinGrote/ModuleFast-action/v0.0.1/action.ps1:37 char:1
2024-10-13T21:43:45.2774764Z + Install-ModuleFast @imfParams @imfCommonParams @args
2024-10-13T21:43:45.2775819Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-10-13T21:43:45.2777525Z + CategoryInfo          : NotSpecified: (:) [Install-ModuleFast], MethodInvocationException
2024-10-13T21:43:45.2778522Z + FullyQualifiedErrorId : ArgumentException,Install-ModuleFast
2024-10-13T21:43:45.4000743Z ##[error]Process completed with exit code 1.

possible cause

It seems the lockfile-hashtable cant accept the same module-name as the key multiple times: https://github.com/JustinGrote/ModuleFast/blob/845784416c3567a0645d30b9649507bb6bdc46b1/ModuleFast.psm1#L443-L450

pipeline / error context

- name: ⚡ ModuleFast with Specification
  uses: JustinGrote/ModuleFast-action@v0.0.1
  with:
    path: './modules.requires.psd1'

The content of specfile modules.requires.psd1:

@{
  'Microsoft365DSC'='=1.24.1002.1'
  'Az.Accounts'='=3.0.2'
  'Az.Resources'='=7.2.0'
  'Az.ResourceGraph'='=1.0.0'
  'Az.SecurityInsights'='=3.1.2'
  'DSCParser'='=2.0.0.10'
  'ExchangeOnlineManagement'='=3.4.0'
  'Microsoft.Graph.Applications'='=2.23.0'
  'Microsoft.Graph.Beta.Applications'='=2.23.0'
  'Microsoft.Graph.Authentication'='=2.23.0'
  'Microsoft.Graph.Beta.DeviceManagement'='=2.23.0'
  'Microsoft.Graph.Beta.Devices.CorporateManagement'='=2.23.0'
  'Microsoft.Graph.Beta.DeviceManagement.Administration'='=2.23.0'
  'Microsoft.Graph.Beta.DeviceManagement.Enrollment'='=2.23.0'
  'Microsoft.Graph.Beta.Identity.DirectoryManagement'='=2.23.0'
  'Microsoft.Graph.Beta.Identity.Governance'='=2.23.0'
  'Microsoft.Graph.Beta.Identity.SignIns'='=2.23.0'
  'Microsoft.Graph.Beta.Reports'='=2.23.0'
  'Microsoft.Graph.Beta.Search'='=2.23.0'
  'Microsoft.Graph.Beta.Teams'='=2.23.0'
  'Microsoft.Graph.DeviceManagement.Administration'='=2.23.0'
  'Microsoft.Graph.Beta.DirectoryObjects'='=2.23.0'
  'Microsoft.Graph.Groups='='=2.23.0'
  'Microsoft.Graph.Beta.Groups'='=2.23.0'
  'Microsoft.Graph.Planner'='=2.23.0'
  'Microsoft.Graph.Sites'='=2.23.0'
  'Microsoft.Graph.Users'='=2.23.0'
  'Microsoft.Graph.Users.Actions'='=2.23.0'
  'Microsoft.PowerApps.Administration.PowerShell'='=2.0.191'
  'MicrosoftTeams'='=6.5.0'
  'MSCloudLoginAssistant'='=1.1.25'
  'PnP.PowerShell'='=1.12.0'
  'ReverseDSC'='=2.0.0.20'
}            

*the list of powershell modules is the modules that will be installed by Microsoft365DSC-cmdlet "Update-M365DSCDependencies"

JustinGrote commented 6 days ago

Good catch! That's definitely an enhancement that needs to be made.