PowerShell / PowerShellGallery

236 stars 65 forks source link

on non-english system Publish-Module fails after creating the nuget package as the script is expecting an "english" output from nuget #296

Closed metanull closed 2 weeks ago

metanull commented 1 month ago

Prerequisites

Steps to reproduce

After a recent upgrade of dotnet, when I attempt to publish a new version of one of my packages (e.g. MetaNullPortfolio), Publish-Module fails with an error message:
Publish-PSArtifactUtility : Failed to generate the compressed file for module 'Indexation impossible dans un tableau Null.'.

Part of the message is in english, part of the message is in french (the language of my system)

After investigating I found out that in Function Publish-PSArtifactUtility, there is a regular expression match performed on the output of dotnet nuget to find the full name of the generated nuget package: $stdOut -match "Successfully created package '(.*.nupkg)'" | Out-Null

But on my system, despite setting the environment variable DOTNET_CLI_UI_LANGUAGE to 'en'; the $stdout contains the output in french: Tentative de g‚n‚ration du package … partir de 'MetaNullPortfolio.nuspec'. AVERTISSEMENTÿ: NU5112: The version of dependency 'SimplySQL' is not specified. Specify the version of dependency and rebuild your package. AVERTISSEMENTÿ: NU5111: The script file 'tools\classes.ps1' is not recognized by NuGet and hence will not be executed during installation of this package. Rename it to install.ps1, uninstall.ps1 or init.ps1 and place it directly under 'tools'. The package MetaNullPortfolio.0.3.41.1 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important. Cr‚ation r‚ussie du package 'C:\Users\phave\AppData\Local\Temp\1713281106\MetaNullPortfolio\MetaNullPortfolio.0.3.41.1.nupkg'.

==> Instead of "Successfully created package", the line reads "Cr‚ation r‚ussie du package"

And therefore the regex match fails. and the Publication of the module stops.

I can work it around by changing the expression in Powershellget's psm1

Expected behavior

PS> Publish-Module -Path $Path -NuGetApiKey $Key
Successfully published module

Actual behavior

PS> Publish-Module -Path $Path -NuGetApiKey $Key
Publish-PSArtifactUtility : Failed to generate the compressed file for module 'Indexation impossible dans un tableau Null.'.

Error details

No response

Environment data

Name                           Value                                                                                                             
----                           -----                                                                                                             
PSVersion                      5.1.19041.4648                                                                                                    
PSEdition                      Desktop                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                           
BuildVersion                   10.0.19041.4648                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                   
WSManStackVersion              3.0                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                               
SerializationVersion           1.1.0.1

Version

PowerShellGet 2.2.5

Visuals

No response

SydneyhSmith commented 3 weeks ago

@metanull you may want to try Microsoft.PowerShell.PSResourceGet to see if it works better for you?

metanull commented 3 weeks ago

Thank you @SydneyhSmith ,i'll give it a try.

https://learn.microsoft.com/fr-fr/powershell/module/microsoft.powershell.psresourceget/?view=powershellget-3.x

metanull commented 2 weeks ago

It worked like a charm with Microsoft.PowerShell.PSResourceGet