PowerShell Error: Publishing Module to Gallery

I recently tried publishing a very small, simple PowerShell module to the PowerShell Gallery. I ran into a few errors that were rather cryptic. To get more debugging information, I ran Publish-Module with the -Verbose switch parameter.

The main errors I noticed were as follows:

Invalid URI: The format of the URI could not be determined.

Publish-PSArtifactUtility : Failed to generate the compressed file for module ‘Attempting to build package from
‘PSHash.nuspec’.’

Publish-PSArtifactUtility : The variable ‘$tempErrorFile’ cannot be retrieved because it has not been set.

The fix ultimately was pretty straightforward. As far as the root cause goes, it turns out that in my module’s manifest file (the module file with the .psd1 file extension), I had specified the license URI as the name of the license file, included with the module (LICENSE) instead of specifying a proper URI. To fix this, I uploaded the license file to my web host, and updated the license URI in the module manifest, and was then able to publish the module successfully.

You can see the error messages in the screenshot below. After fixing the license URI in the PSData section of the module manifest, it published just fine.

powershell-error-publish-module