PowerShell / PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
https://www.PowerShellGallery.com
MIT License
431 stars 138 forks source link

Question: How to publish module to PSGallery with external PSGallery module? #231

Closed ChrisLynchHPE closed 6 years ago

ChrisLynchHPE commented 6 years ago

Apologies for what may be a n00b question. I have a module published in the PSGallery that I have defined RequiredModules in the assembly file. However, the dependencies are not listed in PSGallery listing of my module. When a user attempting to use Install-Module it fails with a dependency missing error. I see quite a number of Azure modules published in PSGallery, but looking at their included module assembly files show they are not using the RequiredModules attribute. What am I missing?

Expected Behavior

To publish a PowerShell module to the PSGallery with listed external module dependencies (note, not binary dependencies.)

Your Environment


> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17101.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17101.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0        chocolateyProfile                   {TabExpansion, Update-SessionEnvironment, refreshenv}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Ge...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable...
Binary     1.0.0.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageP...
Script     1.0.0.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapabil...
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSRead...

> Get-Module -ListAvailable PowerShellGet,PackageManagement

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSo...
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSo...
Script     1.6.0      PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

# I just installed PowerShellGet 1.6.0 before submitting this issue, but have NOT used it to publish my module yet.

> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Co...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, Inst...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Co...
PowerShellGet            1.6.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, Inst...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, Inst...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent
bmanikm commented 6 years ago

@ChrisLynchHPE If the specified module dependencies are available on the PSGallery, it is not required to list them in ExternalModuleDependencies entry --> https://github.com/HewlettPackard/POSH-HPOneView/blob/e630e6de9dbaebc3f64b25753202bb685beb5820/HPOneView.400.psd1#L140 .

A module should be listed in ExternalModuleDependencies only when it is not available on the PSGallery.

ChrisLynchHPE commented 6 years ago

Okay, so I'll remove the External Module Dependencies private data tag. Is that all I need to do?

bmanikm commented 6 years ago

@ChrisLynchHPE Correct, no additional changes are required.

ChrisLynchHPE commented 6 years ago

Thanks @bmanikm.