Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
tmarvin-repay opened this issue Jul 13, 2022 · 1 comment
Closed
3 tasks done

Comments

@tmarvin-repay
Copy link

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_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants