PowerShellGetv2 icon indicating copy to clipboard operation
PowerShellGetv2 copied to clipboard

Cannot push to PSGallery

Open KevinZonda opened this issue 5 years ago • 11 comments

Steps to reproduce

Publish-Module -Name xxxxx -NuGetApiKey xxxx -Verbose

Expected behavior

Work normally

Actual behavior

Publish-PSArtifactUtility : Failed to generate the compressed file for module 'Cannot index into a null array.'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.3\PSModule.psm1:10946 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToCreateCompressedModule,Publish-PSArtifactUtility

image

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18362.628
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.628
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> Get-Module PowerShellGet
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.2.3      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...

KevinZonda avatar Apr 12 '20 03:04 KevinZonda

I found the code which gives the exception

image

KevinZonda avatar Apr 12 '20 05:04 KevinZonda

image

The error in PS 7.

My Windows 10 is 1903. Some 1909 can push successfully.

KevinZonda avatar Apr 18 '20 13:04 KevinZonda

Thanks for pin-pointing the problem! From your original post it seems like the nupkg is getting created properly but somehow parsing the full file name isn't working. Could you let me know if the nupkg exists in the temporary folder that gets created (particularly when running in Windows PS since I see that the nupkg is definitely getting created there)?

alerickson avatar Apr 18 '20 20:04 alerickson

image

@alerickson I think the NUGET package doesn't exist? My Windows user name is chinese, may it affect results?

KevinZonda avatar Apr 19 '20 02:04 KevinZonda

@KevinZonda thank you! That's unfortunate, from the logs it seemed like the .nupkg was getting created properly, but not pushed (possibly due to incorrect parsing), but I'll have to dig in a bit more to see why exactly the nupkg isn't getting created properly.

I have a few more questions for you: Do you have the nuget executable installed? What is your $env:ProgramData path? What is your $env:Path path?

Could you install the nuget exe from https://aka.ms/psget-nugetexe to "C:\Program Files\nuget"?

alerickson avatar Apr 22 '20 22:04 alerickson

I'm seeing this behaviour as well (V 2.2.4). If needed, I can provide additional information about my system and environment. dotnet SDK is installed as well. Using WindowsPowershell mitigates the problem (V 2.0.1)

ProcMon Traces and similar would be possible, as well as screen sharing via Teams or S4B

glatzert avatar May 18 '20 06:05 glatzert

I'm seeing this behaviour as well (V 2.2.4). If needed, I can provide additional information about my system and environment. dotnet SDK is installed as well. Using WindowsPowershell mitigates the problem (V 2.0.1)

ProcMon Traces and similar would be possible, as well as screen sharing via Teams or S4B

I install dotnet SDK too. What's ur Windows build? 1809, or...?

KevinZonda avatar May 18 '20 15:05 KevinZonda

The latest installed dotnet SDK is 3.1.202 Windows Version is 1903

glatzert avatar May 18 '20 15:05 glatzert

The latest installed dotnet SDK is 3.1.202 Windows Version is 1903

I want to upgrade my Windows. May it works.

KevinZonda avatar May 18 '20 15:05 KevinZonda

Can you give any progress on this? Or can we provide anything to allow you fixing the bug or providing us a workaround?

glatzert avatar Aug 02 '20 13:08 glatzert

I just did some digging and I think I found the underlying problem:

Text-Parsing!

$stdOut -match "Successfully created package '(.*.nupkg)'" | Out-Null
$nupkgFullFile = $matches[1]

My machine speaks german. It'll probably report "Nuget-Packet erfolgreich erstellt" or something similar.

glatzert avatar Aug 02 '20 14:08 glatzert