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

Publish-Module breaks if $OFS is set to anything but " " #530

Open

Description

Steps to reproduce

$OFS = ", "
Publish-Module -Name Example -Repository SomeRepo

Expected behavior

Module published.

Actual behavior

Failed to generate the compressed file for module 'C:\Tools\nuget.exe failed to pack: error Unknown command: 'pack,'
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2\PSModule.psm1:10945 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToCreateCompressedModule,Publish-PSArtifactUtility

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18362.145
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18362.145}
BuildVersion                   10.0.18362.145
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement
    Directory: C:\Users\me\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.3      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     2.2        PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.3      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.4.2      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     2.2        PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module, ...
> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
nuget                    2.8.5.208
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            2.2.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
PowerShellGet            1.0.0.1
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent
> nuget help
NuGet Version: 5.1.0.6013

Additional information

My debugging attempts tracked the issue down to this line in New-NugetPackage:

$processStartInfo.Arguments = $ArgumentList

This casts an array ($ArgumentList) to a string, assuming that it will be joined with spaces. This is only true if $OFS is set to " ", which, while currently the default, is not guaranteed.

This bug exists in other functions called during the publishing process, but New-NugetPackage is the first one to trigger it.

Proposed solution

One of:

  1. Explicitly join the array with spaces using -join.
  2. Don't generate an array at all, and directly set $processStartInfo.Arguments to a string with appropriate interpolations.

Activity

  1. SydneyhSmith commented on Aug 22, 2019

    @SydneyhSmith
    Collaborator

    @alexbuzzbee thanks for reporting this bug, and taking the time to do some de-bugging...both of your proposed solutions seem valid, although we are undertaking a major re-work of PowerShellGet right now so I cannot promise we will have bandwidth to address this in the near future (although we do accept PRs 😄 )...thanks!

  2. marckassay commented on Nov 13, 2019

    @marckassay

    ... although we are undertaking a major re-work of PowerShellGet right now ...

    Sydney Smith (@SydneyhSmith) can you please provide more information on this?

  3. SydneyhSmith commented on Nov 14, 2019

    @SydneyhSmith
    Collaborator

    Yes--the RFC is here: PowerShell/PowerShell-RFC#185
    We are targeting a public preview for this module by the end of this year.

  4. marckassay commented on Nov 15, 2019

    @marckassay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions