PowerShellGetv2 icon indicating copy to clipboard operation
PowerShellGetv2 copied to clipboard

Single entry in ExternalModuleDependencies not respected

Open PrzemyslawKlys opened this issue 4 years ago • 3 comments

Here's a simple PSD1 file

@{
    AliasesToExport      = 'Connect-POP3', 'Disconnect-POP3', 'Get-POP3Message', 'Save-POP3Message'
    Author               = 'Przemyslaw Klys'
    CompanyName          = 'Evotec'
    CompatiblePSEditions = 'Desktop', 'Core'
    Copyright            = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
    Description          = 'Mailing helper'
    FunctionsToExport    = 'Connect-IMAP', 'Connect-POP', 'Disconnect-IMAP', 'Disconnect-POP', 'Get-IMAPFolder', 'Get-IMAPMessage', 'Get-POPMessage', 'Save-POPMessage', 'Send-EmailMessage'
    GUID                 = '2b0ea9f1-3ff1-4300-b939-106d5da608fa'
    ModuleVersion        = '0.0.1'
    PowerShellVersion    = '5.1'
    PrivateData          = @{
        PSData = @{
            Tags                       = 'Windows', 'MacOS', 'Linux', 'Mail', 'Email'
            ExternalModuleDependencies = 'Microsoft.PowerShell.Utility'
        }
    }
    RequiredModules      = 'Microsoft.PowerShell.Utility'
    RootModule           = 'Mailozaurr.psm1'
}

It seems that when there's only one RequiredModules or ExternalModuleDependencies it is ignored by PowerShellGet. If there are more external module dependencies it will work.

Publish-PSArtifactUtility : PowerShellGet cannot resolve the module dependency 'Microsoft.PowerShell.Utility' of the module 'Mailozaurr' on the repository 'PSGallery'. Verify that the dependent module 'Microsoft.PowerShell.Utility' is available in the repository 'PSGallery'. If this dependent module 'Microsoft.PowerShell.Utility' is managed externally, add it to the Exter
nalModuleDependencies entry in the PSData section of the module manifest.
At C:\Users\przemyslaw.klys\Documents\WindowsPowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:10944 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Publish-PSArtifactUtility], InvalidOperationException
    + FullyQualifiedErrorId : UnableToResolveModuleDependency,Publish-PSArtifactUtility

PrzemyslawKlys avatar Jun 13 '20 07:06 PrzemyslawKlys

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.90. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Jun 13 '20 07:06 issue-label-bot[bot]

It appears to me this might not really be an issue. Both RequiredModules and ExternalModuleDependencies are supposed to take arrays. This provides a string value. RequiredModules = 'Microsoft.PowerShell.Utility' This provides an array value RequiredModules = @('Microsoft.PowerShell.Utility')

Does it fail when specifying an array?

danmetzler avatar Jul 08 '21 18:07 danmetzler

It fails only when it's a string value. Works fine with an array, including array with 1 element.

PrzemyslawKlys avatar Jul 08 '21 18:07 PrzemyslawKlys