Amadevus / pwsh-script

GitHub Action to run PowerShell scripts in a rich, prepared scope - inspired by actions/github-script.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: ConvertTo-Json : An item with the same key has already been added. Key: Version

sergey-s-betke opened this issue · comments

Please, help me with pwsh-script action:

https://github.com/test-st-petersburg/DocTemplates/runs/2487220589?check_suite_focus=true#step:4:70

Code:

<#
.SYNOPSIS
Sanitizes an input into a string so it can be passed into issueCommand safely.
Equivalent of `core.toCommandValue(input)`.
.PARAMETER Value
Input to sanitize into a string.
#>
function ConvertTo-ActionCommandValue {
[CmdletBinding()]
[OutputType([string])]
param(
[Parameter(Mandatory, Position = 0)]
[AllowNull()]
[AllowEmptyString()]
[AllowEmptyCollection()]
[object]$Value
)
if ($null -eq $Value) {
return ''
}
if ($Value -is [string]) {
return $Value
}
return ConvertTo-Json $Value -Depth 100 -Compress -EscapeHandling EscapeNonAscii
}

After any call to Install-Package -ProviderName NuGet ... i have there error. With -verbose and without -verbose. What is it?

Error source:

Register-PackageSource -Name 'nuget.org' -Location 'https://api.nuget.org/v3/index.json' -ProviderName NuGet -Trusted -Force -Verbose;

Workaround:

Register-PackageSource -Name 'nuget.org' -Location 'https://api.nuget.org/v3/index.json' -ProviderName NuGet -Trusted -Force -Verbose | Out-Null;