Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

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

Open
Stephanevg opened this issue Jun 1, 2020 · 26 comments

Comments

@Stephanevg
Copy link

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

@franklupo
Copy link

Same problem!
News

@franklupo
Copy link

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

Best regards

@Machibuse
Copy link

Same Problem here under windows.

no solution, i cant publish

@yamamoWorks
Copy link

Same Problem here under windows too.

@yamamoWorks
Copy link

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

@franklupo
Copy link

I use Italian. What is the solution?

Best regards

@Machibuse
Copy link

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

@franklupo
Copy link

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

Wich version?

Best regards

@Machibuse
Copy link

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

@potatoqualitee
Copy link

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/

@mzros
Copy link

mzros commented Feb 8, 2021

Same problem here under windows

@LxLeChat
Copy link

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.

@yuusakuri
Copy link

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', $_)
}

@chausner
Copy link

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

This was also the issue on my German system.

@LxLeChat
Copy link

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

@alerickson
Copy link
Member

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.

@chausner
Copy link

chausner commented Aug 24, 2021

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.

@StevenBucher98
Copy link
Collaborator

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.

@chausner
Copy link

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.

@mighty-services
Copy link

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

@YIsoda
Copy link

YIsoda commented Jul 12, 2022

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"

@ouromoros
Copy link

@YIsoda Your solution is by far the easiest and most intuitive! I really hate it that this issue is present even after 3 years...

@dlothmann
Copy link

@YIsoda Problem solved the same way on my Win11 German. Thanks a lot.

@SeryiBaran
Copy link

SeryiBaran commented Jul 7, 2023

All methods except downgrade nuget to 5.0.2 doesn't work :(

Any news?

@SeryiBaran
Copy link

I fix it by installing Dotnet 7 and running @YIsoda command - $env:DOTNET_CLI_UI_LANGUAGE="en_US".

Thanks!

@ecarbone
Copy link

For those people still having the problem, there is an environment variable named NUGET_CLI_LANGUAGE, similar to DOTNET_CLI_UILANGUAGE, you have to set it to "en-us" in order to New-NugetPackage.ps1 to work. This was tested in Powershell version 2.2.5. See reference: NuGet/Home#12181

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests