PowerShellGetv2 icon indicating copy to clipboard operation
PowerShellGetv2 copied to clipboard

Failed to generate the compressed file for module 'Cannot index into a null array'.

Open Stephanevg opened this issue 4 years ago • 26 comments

I am trying to publish a module from a MacOS. @SydneyhSmith tagging you hopping you can help resolve this one quickly.

Steps to reproduce

Publish-Module -Name FakeFile -NuGetApiKey $ApiKey -Verbose

Expected behavior

Publish to module the gallery

Actual behavior


Publish-Module -Name FakeFile -NuGetApiKey $ApiKey -Verbose

VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Publish Location:'https://www.powershellgallery.com/api/v2/package/'.
VERBOSE: Module 'FakeFile' was found in '/Users/stephanevg/.local/share/powershell/Modules/FakeFile'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/items/psscript' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/items/psscript/FindPackagesById()?id='FakeFile'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'FakeFile'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='FakeFile'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'FakeFile'.
VERBOSE: Performing the operation "Publish-Module" on target "Version '1.0.0' of module 'FakeFile'".
VERBOSE: Calling Publish-PSArtifactUtility
VERBOSE: Calling New-NuspecFile
VERBOSE: Calling New-NugetPackage
VERBOSE: Calling /usr/local/share/dotnet/dotnet pack "/var/folders/vq/hqgkv59j4qn_pdk5shxnlfnm0000gn/T/1dbbd074-ce96-4fff-99c9-0b6beac99272/Temp.csproj" /p:NuspecFile="/var/folders/vq/hqgkv59j4qn_pdk5shxnlfnm0000gn/T/1970254736/FakeFile/FakeFile.nuspec" --output "/var/folders/vq/hqgkv59j4qn_pdk5shxnlfnm0000gn/T/1970254736/FakeFile"
VERBOSE: /usr/local/share/dotnet/dotnet output:
VERBOSE:        Microsoft (R) Build Engine version 16.5.0+d4cbfca49 pour .NET Core
VERBOSE:        Copyright (C) Microsoft Corporation. Tous droits réservés.
VERBOSE: 
VERBOSE:          Restauration effectuée dans 207,53 ms pour /var/folders/vq/hqgkv59j4qn_pdk5shxnlfnm0000gn/T/1dbbd074-ce96-4fff-99c9-0b6beac99272/Temp.csproj.
VERBOSE:          Temp -> /var/folders/vq/hqgkv59j4qn_pdk5shxnlfnm0000gn/T/1dbbd074-ce96-4fff-99c9-0b6beac99272/bin/Debug/netcoreapp2.0/NotUsed.dll
VERBOSE:          Création réussie du package '/var/folders/vq/hqgkv59j4qn_pdk5shxnlfnm0000gn/T/1970254736/FakeFile/FakeFile.1.0.0.nupkg'.
VERBOSE: 
VERBOSE: finished running /usr/local/share/dotnet/dotnet with exit code 0
Write-Error: /Users/stephanevg/.local/share/powershell/Modules/PowerShellGet/2.2.4.1/PSModule.psm1:10988:17
 Line |
10988 |  …             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param …
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Failed to generate the compressed file for module 'Cannot index into a null
      | array.'.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.1
PSEdition                      Core
GitCommitId                    7.0.1
OS                             Darwin 19.5.0 Darwin Kernel Version 19.5.0: Thu Apr 30 18:25:59 PDT 2020; roo…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

 Get-Module -ListAvailable PowerShellGet,PackageManagement


    Directory: /Users/stephanevg/.local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, G…
Script     2.2.4.1               PowerShellGet                       Desk      {Find-Command, Find-DSCResour…

    Directory: /usr/local/microsoft/powershell/7/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, G…
Script     2.2.4                 PowerShellGet                       Desk      {Find-Command, Find-DSCResour…


PS /Users/stephanevg/Code> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, Fil…
PowerShellGet            2.2.4.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublishe…
PowerShellGet            2.2.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublishe…

I went and debugged a little bit setting a breakpoint here and there. I noticed that the splatted variable was missing some values that were actually set in my psd1 file (Tags and ProjectURI for what I could tell).

I am currently blocked as I need to publish public this module, but I have only this way to do so (there is not a way of doing it via the website).

Stephanevg avatar Jun 01 '20 21:06 Stephanevg

Same problem! News

franklupo avatar Jul 06 '20 15:07 franklupo

Hi, I am currently blocked as I need to publish, how can I do?

Best regards

franklupo avatar Jul 14 '20 14:07 franklupo

Same Problem here under windows.

no solution, i cant publish

Machibuse avatar Aug 26 '20 11:08 Machibuse

Same Problem here under windows too.

yamamoWorks avatar Sep 03 '20 15:09 yamamoWorks

Cause is language maybe...

This script will search standard-out of dotnet command with text message.

[src\PowerShellGet\private\functions\New-NugetPackage.ps1] $stdOut -match "Successfully created package '(.*.nupkg)'" | Out-Null $nupkgFullFile = $matches[1]

My computer run in Japanese, dotnet command output is Japanese. パッケージ 'C:\Windows\Temp\1346427969\FooBar\FooBar.0.0.1.nupkg' が正常に作成されました。

So It's not match!

$matches is null. --> 'Cannot index into a null array.'

yamamoWorks avatar Sep 03 '20 18:09 yamamoWorks

I use Italian. What is the solution?

Best regards

franklupo avatar Sep 04 '20 14:09 franklupo

I downgraded to an older version and replaced the nuget.exe with an actual version. this worked for me.

Machibuse avatar Sep 04 '20 16:09 Machibuse

I downgraded to an older version and replaced the nuget.exe with an actual version. this worked for me.

Wich version?

Best regards

franklupo avatar Sep 04 '20 16:09 franklupo

I downgraded to an older version and replaced the nuget.exe with an actual version. this worked for me.

Wich version?

Best regards

Sorry for the Late answer, i was not at work for the last days.

I downgraded PowerShellGet To 1.0.0.1

After the first usage of Publish-Module there will be an old nuget.exe at

C:\Users<UserName>\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\

I replaced the nuget.exe with with version 5.6.0.6591

Then Publish-Module works fine for me.

Maybe you also need to set the correct TLS Version in the PowerShell Console with

[PS]> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Machibuse avatar Sep 10 '20 13:09 Machibuse

Having the same problem, seemingly out of nowhere. I used this blog to solve my problem: https://sqldbawithabeard.com/2019/11/26/fixing-the-failed-to-generate-the-compressed-file-for-module-cprogram-filesdotnetdotnet-exe-error-when-deploying-to-the-powershell-gallery-using-azure-devops/

potatoqualitee avatar Jan 18 '21 18:01 potatoqualitee

Same problem here under windows

mzros avatar Feb 08 '21 16:02 mzros

Hello same problem here. had to change a line in the powershellget.psm1 ... even after installing the powershellget 3.0.0 latest beta version...

for me the problem was located in the New-NugetPackage function

had to change:

$stdOut -match "Successfully created package '(.*.nupkg)'" | Out-Null

to

$stdOut -match "Création réussie du package '(.*.nupkg)'" | Out-Null

because i'm working on a french version of windows.

LxLeChat avatar May 30 '21 13:05 LxLeChat

I ran the following code in PowerShell to fix the problem.

"$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe" |
Where-Object { !(Test-Path -LiteralPath $_ -PathType Leaf) } |
ForEach-Object {
    (New-Object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', $_)
}

yuusakuri avatar Jul 03 '21 11:07 yuusakuri

for me the problem was located in the New-NugetPackage function

This was also the issue on my German system.

chausner avatar Aug 24 '21 18:08 chausner

Did someone tested the new v3 ??? I asked on twitter but no one answered... :(

LxLeChat avatar Aug 24 '21 18:08 LxLeChat

I would love to know if using v3 helps to resolve this issue (https://www.powershellgallery.com/packages/PowerShellGet/3.0.11-beta). If not we can't proceed to make bug fixes and updates there.

alerickson avatar Aug 24 '21 19:08 alerickson

I would love to know if using v3 helps to resolve this issue (https://www.powershellgallery.com/packages/PowerShellGet/3.0.11-beta). If not we can't proceed to make bug fixes and updates there.

How do I install PowerShellGet 3.0.11-beta? Even after putting it into my modules folder and importing it, whenever I run Publish-Module it continues to load the stable version from C:\program files\windowsapps\microsoft.powershell_7.1.4.0_x64__8wekyb3d8bbwe\Modules\PowerShellGet.

Also tried Update-Module -Name PowerShellGet -AllowPrerelease:

Update-Module: Module 'PowerShellGet' was not installed by using Install-Module, so it cannot be updated.

chausner avatar Aug 24 '21 19:08 chausner

Please run the following steps: Install-Module PowerShellGet -version "3.0.11-beta" -AllowPrerelease -Repository PSGallery

Import-Module PowerShellGet

Publish-PSResource -path <PATH_TO_MODULE> -Repository PSGallery -apikey <API_KEY>

Let us know if this works for you. This is specifically for publishing to the PowerShell Gallery.

StevenBucher98 avatar Aug 26 '21 18:08 StevenBucher98

Please run the following steps: Install-Module PowerShellGet -version "3.0.11-beta" -AllowPrerelease -Repository PSGallery

Import-Module PowerShellGet

Publish-PSResource -path <PATH_TO_MODULE> -Repository PSGallery -apikey <API_KEY>

Let us know if this works for you. This is specifically for publishing to the PowerShell Gallery.

Thanks, I can confirm that I could successfully publish using 3.0.11-beta and the command you suggested.

chausner avatar Aug 26 '21 21:08 chausner

for me the problem was located in the New-NugetPackage function

This was also the issue on my German system.

Hy chausner,

thanks for you´re answer. I also have a German windows with the same error. To what text do i need to change it since I don´t know how to capture the $stdout variable

mighty-services avatar Jun 28 '22 20:06 mighty-services

I also encountered the same problem in a Japanese Windows 11 machine. .NET CLI output language was Japanese in my environment, so I set it to English (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_cli_ui_language) as follows, which seems to have solved the problem.

$env:DOTNET_CLI_UI_LANGUAGE="en_US"

YIsoda avatar Jul 12 '22 07:07 YIsoda