PSResourceGet icon indicating copy to clipboard operation
PSResourceGet copied to clipboard

New-ModuleManifest generates ExternalModuleDependencies settings that are incompatible with Publish-Module

Open testworksau opened this issue 4 years ago • 2 comments

The following command:

New-ModuleManifest -Path .\Test.psd1 -RequiredModules @('AWSPowerShell.NetCore') -ExternalModuleDependencies @('AWSPowerShell.NetCore') -PassThru

results in the following manifest being generated (irrelevant data excluded):

...
RequiredModules = @('AWSPowerShell.NetCore')
...
PrivateData = @{
    PSData = @{
    ...
        # External dependent modules of this module
        ExternalModuleDependencies = 'AWSPowerShell.NetCore'
    } # End of PSData hashtable
} # End of PrivateData hashtable
...

Note that ExternalModuleDependencies is not a String array as defined by the documentation. This output appears to be incompatible with Publish-Module as I receive the following error using this .psd1 file:

WARNING: PowerShellGet cannot resolve the module dependency 'AWSPowerShell.NetCore' of the module 'Test' on the repository 'local'. Verify that the dependent module 'AWSPowerShell.NetCore' is available in the repository 'local'. If this dependent module 'AWSPowerShell.NetCore' is managed externally, add it to the ExternalModuleDependencies entry in the PSData section of the module manifest.

Adding a dummy entry to the ExternalModuleDependencies string array:

New-ModuleManifest -Path .\Test.psd1 -RequiredModules @('AWSPowerShell.NetCore') -ExternalModuleDependencies @('AWSPowerShell.NetCore', 'dummy') -PassThru

Generates the following structure which allows publishing to succeed:

...
RequiredModules = @('AWSPowerShell.NetCore')
...
PrivateData = @{
    PSData = @{
    ...
        # External dependent modules of this module
        ExternalModuleDependencies = 'AWSPowerShell.NetCore', 'dummy'
    } # End of PSData hashtable
} # End of PrivateData hashtable
...

Similarly, manually setting ExternalModuleDependencies to @(AWSPowerShell.NetCore) by editing the generated .psd1 file allows publishing to succeed.

The same structure is generated using the dotnet/sdk:5.0 docker container (PowerShell 7.1.3)

$PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

and the dotnet/sdk:3.1 docker container (PowerShell 7.0.6)

$PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.0.6
PSEdition                      Core
GitCommitId                    7.0.6
OS                             Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

testworksau avatar May 24 '21 04:05 testworksau

Thanks @testworksau we will try to incorporate this fix/test this scenario as we complete new Publish functionality for v3

SydneyhSmith avatar May 27 '21 18:05 SydneyhSmith

I came to complain about this not working at all, but I guess maybe I'll try explicitly wrapping it in an array? This needs to be backwards compatible...

Jaykul avatar Aug 11 '22 01:08 Jaykul