PSResourceGet icon indicating copy to clipboard operation
PSResourceGet copied to clipboard

LicenseUri in .psd1 getting incorrectly written as license in .nuspec

Open fsackur opened this issue 2 years ago • 0 comments

Prerequisites

  • [X] Write a descriptive title.
  • [X] Make sure you are able to repro it on the latest released version
  • [X] Search the existing issues.

Steps to reproduce

PSGet beta 17 will not publish my PowerShell module:

❯ Publish-PSResource -Path ./Build/Karabiner/ -ApiKey $ApiKey -Repository PSGallery
VERBOSE: Creating new nuspec file.
VERBOSE: The newly created nuspec is: /var/folders/d8/4ztprr111hb_nnt5jcskdn400000gn/T/00994448-00a6-4582-a4d0-2b70c8f5fb21/Karabiner.nuspec
Publish-PSResource: Unexpectd error packing into .nupkg: 'An error occured while trying to parse the value 'http://raw.githubusercontent.com/fsackur/Karabiner/main/LICENSE' of property 'license' in the manifest file.'.
VERBOSE: Deleting temporary directory '/var/folders/d8/4ztprr111hb_nnt5jcskdn400000gn/T/00994448-00a6-4582-a4d0-2b70c8f5fb21'

Karabiner.psd1 contains:

    PrivateData          = @{
        PSData = @{
            LicenseUri = 'http://raw.githubusercontent.com/fsackur/Karabiner/main/LICENSE'
            ProjectUri = 'https://github.com/fsackur/Karabiner'

That generated .nuspec contains:

    <id>Karabiner</id>
    <license>https://raw.githubusercontent.com/fsackur/Karabiner/main/LICENSE</license>
    <projectUrl>https://github.com/fsackur/Karabiner</projectUrl>

I suspect that needs to be licenseUrl, not license: https://learn.microsoft.com/en-us/nuget/reference/nuspec#license

Beta16 works.

FWIW, I'm on MacOS Monterey, and I can repro with PackageManagement 1.4.7 and 1.4.8.1.

❯ Get-PackageProvider NuGet | fl * 

Name                    : NuGet
ProviderName            : NuGet
Features                : {[supports-powershell-modules, System.Collections.Generic.List`1[System.String]], [file-extensions, System.Collections.Generic.List`1[System.String]], [uri-schemes, System.Collections.Generic.List`1[System.String]], [magic-signatures, 
                          System.Collections.Generic.List`1[System.String]]}
Version                 : 3.0.0.1
ProviderPath            : /Users/freddie/.local/share/powershell/Modules/PackageManagement/1.4.8.1/coreclr/netstandard2.0/Microsoft.PackageManagement.NuGetProvider.dll
SupportedFileExtensions : {nupkg}

Expected behavior

Module is published.

Actual behavior

Module is not published. Error is shown:

`Publish-PSResource: Unexpectd error packing into .nupkg: 'An error occured while trying to parse the value 'http://raw.githubusercontent.com/fsackur/Karabiner/main/LICENSE' of property 'license' in the manifest file.'.`

Error details

❯ Get-Error

Exception             : 
    Type    : System.ArgumentException
    Message : Unexpectd error packing into .nupkg: 'An error occured while trying to parse the value 'http://raw.githubusercontent.com/fsackur/Karabiner/main/LICENSE' of property 'license' in the manifest file.'.
    HResult : -2147024809
CategoryInfo          : NotSpecified: (:) [Publish-PSResource], ArgumentException
FullyQualifiedErrorId : ErrorPackingIntoNupkg,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource
InvocationInfo        : 
    MyCommand        : Publish-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 44
    Line             : Publish-PSResource -Path ./Build/Karabiner/ -ApiKey $ApiKey -Repository PSGallery
    PositionMessage  : At line:1 char:1
                       + Publish-PSResource -Path ./Build/Karabiner/ -ApiKey $ApiKey -Reposito …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Publish-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

❯ Get-Module PowerShellGet

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     3.0.17     beta17     PowerShellGet                       {Find-PSResource, Get-PSResource, Get-PSResourceRepository, Install-PSResource…}

❯ $PSVersionTable         

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

fsackur avatar Oct 18 '22 23:10 fsackur