PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
485 stars 92 forks source link

Install-PSResource: Input string was not in a correct format (GitLab) #239

Closed brajjan closed 1 year ago

brajjan commented 4 years ago

Trying to install powershell module located on gitlab packages source

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Get-PSResourceRepository

Name       Url                                                                     Trusted Priority
----       ---                                                                     ------- --------
PSGallery  https://www.powershellgallery.com/api/v2                                false   50
TempSource https://internal-gitlab/api/v4/projects/1234/packages/nuget/index.json  false   50
Get-PackageSource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
TempSource                       PowerShellGet    False      https://internal-gitlab/api/v4/projects/1234/packages/nuget/index.json
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2
Find-PSResource -Name ActiveDirectoryDsc -Repository TempSource -Credential $Credential

Name               Version Repository Description
----               ------- ---------- -----------
ActiveDirectoryDsc 6.0.1   TempSource
Install-PSResource -Name ActiveDirectoryDsc -Repository TempSource -Credential $Credential

Install-PSResource: Input string was not in a correct format.
Get-Error

Exception             :
    Type       : System.FormatException
    TargetSite :
        Name          : FormatError
        DeclaringType : System.Text.StringBuilder
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    StackTrace :
   at System.Text.StringBuilder.FormatError()
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.Format(String format, Object[] args)
   at Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallHelper.ProcessInstallParams(String[] _name, String _version, Boolean _prerelease, String[] _repository, String _scope, Boolean _acceptLicense, Boolean _quiet, Boolean _reinstall,
Boolean _force, Boolean _trustRepository, Boolean _noClobber, PSCredential _credential, String _requiredResourceFile, String _requiredResourceJson, Hashtable _requiredResourceHash)
   at Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
    Message    : Input string was not in a correct format.
    Source     : System.Private.CoreLib
    HResult    : -2146233033
CategoryInfo          : NotSpecified: (:) [Install-PSResource], FormatException
FullyQualifiedErrorId : System.FormatException,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource
InvocationInfo        :
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 285
    Line             : Install-PSResource -Name ActiveDirectoryDsc -Repository TempSource -Credential $Credential
    PositionMessage  : At line:1 char:1
                       + Install-PSResource -Name ActiveDirectoryDsc -Repository TempSource -C …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.85. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

alerickson commented 4 years ago

Thanks for opening this issue! We have not tested/do not currently have support for GitLab packages, but will ensure we update PowerShellGet to work with this source.

robinmalik commented 1 year ago

FWIW @brajjan, I'm unable to replicate this in my environment. Here are the details:

GitLab version: 15.6.0-ee

$PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Microsoft Windows 10.0.25267
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Get-PSResourceRepository:

Name      Uri                                                                      Trusted Priority
----      ---                                                                      ------- --------
PSGallery https://www.powershellgallery.com/api/v2                                 False   1
GitLab    https://mygitlab.domain.com/api/v4/projects/406/packages/nuget/index.json True    50

Get-PackageSource (note, there's no source for GitLab here):

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
MyNuGet                          NuGet            False      https://www.nuget.org/api/v2

Find-PSResource -Name TagTest -Repository GitLab -Credential $Credential:

Name    Version  Prerelease Repository Description
----    -------  ---------- ---------- -----------
TagTest 1.0.49.0            GitLab     

The installation (Install-PSResource -Name TagTest -Repository GitLab -Credential $Credentials) works fine.

If it's not still an issue for you, perhaps this case can be closed.

alerickson commented 1 year ago

This should be resolved with the latest changes to v3 repositories. Our next release (beta23) will have further support for GitLab repos.