Skip to content

Publish-PSResource does not properly read #PSScriptInfo if value is separated by newline #701

@tmarvin-repay

Description

@tmarvin-repay

Prerequisites

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

Steps to reproduce

Publish-PSResource does not properly parse the PSScriptInfo comment header if the key (ex: .VERSION) is separated from the value by a newline.

For example this header works:

<#PSScriptInfo
.VERSION 1.0.0

.GUID a2777fce-98e1-4e26-b0df-d698a755c259

.AUTHOR	Test Author

.COMPANYNAME Test Company

.COPYRIGHT Test CopyRight

.PROJECTURI https://google.com/
#>

<#
.DESCRIPTION
 A verbose description!
#>
Param()

However this does not.

<#PSScriptInfo
.VERSION
 1.0.0

.GUID
 a2777fce-98e1-4e26-b0df-d698a755c259

.AUTHOR
 Test Author

.COMPANYNAME
 Test Company

.COPYRIGHT
 Test CopyRight

.PROJECTURI
 https://google.com/
#>

<#
.DESCRIPTION
 test
#>
Param()

It seems inconsistent to me that the description can be separated by a newline but that the other parameters cannot.

Expected behavior

The script header is parsed successfully and a nuget package is produced regardless of the whitespace after a comment header.

Actual behavior

An error is generated with some variation of `No version was provided in the script metadata. Script metadata must specify a version, author, description, and Guid.` (depends on which is missing [version, author, Guid]).

Error details

Exception             :
    Type    : System.ArgumentException
    Message : No author was provided in the script metadata. Script metadata must specify a version, author, description, and Guid.
    HResult : -2147024809
CategoryInfo          : InvalidData: (:) [Publish-PSResource], ArgumentException
FullyQualifiedErrorId : MissingAuthorInScriptMetadata,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource
InvocationInfo        :
    MyCommand        : Publish-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 24
    Line             : Publish-PSResource -Path 'C:\Users\tmarvin\Desktop\testScript.ps1' -DestinationPath C:\Work\
    PositionMessage  : At line:1 char:1
                       + Publish-PSResource -Path 'C:\Users\tmarvin\Desktop\testScript.ps1' -D …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Publish-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :


### Environment data

```powershell
Get-Module PowerShellGet; $PSVersionTable

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

Key   : PSVersion
Value : 7.2.5
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 7.2.5
Name  : GitCommitId


Key   : OS
Value : Microsoft Windows 10.0.19044
Name  : OS


Key   : Platform
Value : Win32NT
Name  : Platform


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name  : PSCompatibleVersions


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion


### Visuals

_No response_

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions