PowerShell / PowerShellGetv2

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

Cannot push to PSGallery #597

Open KevinZonda opened 4 years ago

KevinZonda commented 4 years ago

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 commented 4 years ago

I found the code which gives the exception

image

KevinZonda commented 4 years ago

image

The error in PS 7.

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

alerickson commented 4 years ago

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)?

KevinZonda commented 4 years ago

image

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

alerickson commented 4 years ago

@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\"?

glatzert commented 4 years ago

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

KevinZonda commented 4 years ago

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...?

glatzert commented 4 years ago

The latest installed dotnet SDK is 3.1.202 Windows Version is 1903

KevinZonda commented 4 years ago

The latest installed dotnet SDK is 3.1.202 Windows Version is 1903

I want to upgrade my Windows. May it works.

glatzert commented 4 years ago

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

glatzert commented 4 years ago

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.