Skip to content

Register-PSResourceRepository is not accepting UNCs or File:// uris for local, file share nuget repositories #496

@AspenForester

Description

@AspenForester

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

When attempting to register a local file-share-based Nuget repository, I consistently get errors. This works on Register-PSRepository from PowerShellGet 2.2.5 and earlier.

PS>  Register-PSResourceRepository -Name HCGallery -url \\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\ -Trusted
Register-PSResourceRepository: The URL provided is not valid: Microsoft.PowerShell.Core\FileSystem::\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\
PS>  Register-PSResourceRepository -Name HCGallery -url file:\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\ -Trusted
Register-PSResourceRepository: The URL provided is not valid: file:\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\ and must be of Uri Scheme: HTTP, HTTPS, FTP or File
PS>  Register-PSResourceRepository -Name HCGallery -url "file://hcgg/lobroot/ITxx/team/NuGet" -Trusted 
Register-PSResourceRepository: The URL provided is not valid: file://hcgg/lobroot/ITxx/team/NuGet and must be of Uri Scheme: HTTP, HTTPS, FTP or File

Expected behavior

PS> Register-PSResourceRepository -Name HCGallery -url \\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\ -Trusted

Name      Url                                      Trusted Priority
----      ---                                      ------- --------
HCGallery \\hcgg.rest.of.domain.name\lobroot\IT...    True       50

The local repository should be registered

Actual behavior

Register-PSResourceRepository: The URL provided is not valid: Microsoft.PowerShell.Core\FileSystem::\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\

or 

Register-PSResourceRepository: The URL provided is not valid: file:\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\ and must be of Uri Scheme: HTTP, HTTPS, FTP or File

Error details

Exception             :
    Type       : System.ArgumentException
    Message    : The URL provided is not valid:
Microsoft.PowerShell.Core\FileSystem::\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet\
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.1.4.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
    Source     : System.Management.Automation
    HResult    : -2147024809
CategoryInfo          : InvalidArgument: (:) [Register-PSResourceRepository], ArgumentException
FullyQualifiedErrorId : InvalidUrl,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository
InvocationInfo        :
    MyCommand        : Register-PSResourceRepository
    ScriptLineNumber : 1
    OffsetInLine     : 2
    HistoryId        : 62
    Line             :  Register-PSResourceRepository -Name HCGallery -url
\\hcgg.fr.co.hennepin.mn.us\lobroot\ITxx\team\NuGet\
    PositionMessage  : At line:1 char:2
                       +  Register-PSResourceRepository -Name HCGallery -url \\hcgg.rest.of.do …
                       +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Register-PSResourceRepository
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Exception             :
    Type       : System.ArgumentException
    Message    : The URL provided is not valid: file:\\hcgg.rest.of.domain.name\lobroot\ITxx\team\NuGet and must be
of Uri Scheme: HTTP, HTTPS, FTP or File
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation,
Version=7.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
    Source     : System.Management.Automation
    HResult    : -2147024809
CategoryInfo          : InvalidArgument: (:) [Register-PSResourceRepository], ArgumentException
FullyQualifiedErrorId : InvalidUrl,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository
InvocationInfo        :
    MyCommand        : Register-PSResourceRepository
    ScriptLineNumber : 1
    OffsetInLine     : 2
    HistoryId        : 67
    Line             :  Register-PSResourceRepository -Name HCGallery -url
file:\\hcgg.fr.co.hennepin.mn.us\lobroot\ITxx\team\NuGet
    PositionMessage  : At line:1 char:2
                       +  Register-PSResourceRepository -Name HCGallery -url file:\\hcgg.rest. …
                       +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Register-PSResourceRepository
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     3.0.11     beta       PowerShellGet                       {Find-PSResource, Get-InstalledPSResource, Get-PS…

Key   : PSVersion
Value : 7.1.4
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 7.1.4
Name  : GitCommitId


Key   : OS
Value : Microsoft Windows 10.0.19042
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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions