Reputation: 1165
Problem:
I am unable to successfully publish a non-monolithic script module to my local PowerShell Gallery when using PowerShell 5.1 and my module contains 7 or more functions. Publishes fine with 6 or less functions.
Example: FunctionsToExport = 'Get-Test1', 'Get-Test2 ', 'Get-Test3', 'Get-Test4', 'Get-Test5', 'Get-Test6', 'Get-Test7'
The publish always hangs at 'VERBOSE: Performing the operation "Publish-Module" on target…', but never completes.
I am not seeing any errors, so I am not sure why it is hanging.
What does work:
I can successfully publish my non-monolithic script module to my local PowerShell Gallery when it contains 6 or less functions.
Example: FunctionsToExport = 'Get-Test1', 'Get-Test2 ', 'Get-Test3', 'Get-Test4', 'Get-Test5', 'Get-Test6'
This works fine: VERBOSE: Successfully published module…
If I simply add one more function and update the manifest, I can no longer publish without it hanging again at the same place.
I am pretty sure I am missing a step, but I am having trouble figuring out what I missed.
I am learning the non-monolithic script module design from Mike F Robbins by reading his blog posts and watching his presentations. The gist of this design is each function is in a separate PS1 file that is dot sourced from the PSM1 file.
Summary of how I build my script modules:
This is how I am publishing my module to my local PSGallery.
Publish-Module -Path 'G:\_temp\JnTestModule' -Repository JnPowerShellGallery -NuGetApiKey 'AnyStringWillDo' -Verbose -InformationAction Continue
Here is a OneDrive link to my test module.
https://1drv.ms/f/s!AlsrG1Yfr5pHgts0RCM--SmRnUf3AA
Output of $PSVersionTable
PSVersion 5.1.17134.590
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.590
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I am so close to building my first release pipeline for my PowerShell modules, but I am stuck at this point.
Does anyone know what might be causing this issue?
Upvotes: 3
Views: 201
Reputation: 1165
Ok, I just found out I can publish my module successfully using PowerShell Core 6.2.0!
Joel on http://slack.poshcode.org/ powershell-help channel suggested to change the .psd1 file encoding to UTF8 with BOM. He said PowerShell 5 doesn't like .psd1 files that don't have BOM. They are encoded with UTF8 by default in vscode. I did try changing the encoding, but this did not fix my problem.
Thanks to his suggestion, I thought of trying to publish my module with PowerShell Core 6.2.0 and it worked!
This does not exactly solve the problem with PowerShell 5.1, but I don't mind switching to PowerShell Core 6.2.0 to publish my modules. This solves my problem.
Upvotes: 4