Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

"Unable to resolve package source" when registering PowerShell repository



  • Using a ProGet installation with built-in user security enabled, I am trying to register my PowerShell feed as a repository and install a module from it. I am using a Personal API token to handle authentication. I am trying to run the following in PowerShell:

    $progeturl = "my-proget-url.example.com"
    $repository = "third-party-powershell"
    $apikey = Read-Host -MaskInput # Prompts for API Token
    
    $password = ConvertTo-SecureString $apikey -AsPlainText -Force
    $credential = New-Object System.Management.Automation.PSCredential("api", $password)
    Register-PSRepository -Name $repository -SourceLocation "https://${progeturl}/nuget/${repository}/" -Credential $credential
    

    This results in the following response:

    WARNING: Unable to resolve package source 'https://my-proget-url.example.com/nuget/third-party-powershell/'

    The Get-PSRepository command shows my new "third-party-powershell" module in the list, but when I try to install a module, I get the following output:

    PS C:\> Install-Module -Name "PsIni" -RequiredVersion "3.1.2" -Repository "third-party-powershell"
    WARNING: Unable to resolve package source 'https://my-proget-url.example.com/nuget/third-party-powershell/'.
    Install-Package: No match was found for the specified search criteria and module name 'PsIni'. Try Get-PSRepository to see all available registered module repositories.
    

    If I attempt to register the repository without passing the credential, I get the error: Register-PSRepository: The specified Uri 'https://my-proget-url.example.com/nuget/third-party-powershell/' for parameter 'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.

    Using the -Credential flag in the Install-Module call does not make a difference in the returned output. I have no configured proxy that could be impacting the register or install calls.

    I'm a little stumped! How can I use PowerShell feeds configured in my ProGet installation?


  • inedo-engineer

    Hi @curtis-denotter_1361 ,

    It looks like you're following the right steps; here is our HOW-TO guide on the topic:
    https://docs.inedo.com/docs/proget-powershell-private-module-repository

    If I had to guess, the issue is with HTTPS/TLS resolution. That's what most search results for "Unable to resolve package source" came up with, anyway. You'd have to use a tool like Wireshark to be sure, since the error message from PowerShell isn't very helpful.

    You can force PowerShell to use TLS12:
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    It might also be certificate related. You may get a better error message if you do like a Invoke-WebRequest to your ProGet URL.

    Cheers,
    Alana



  • Hello and thanks for the suggestions, @atripp!

    I tried doing an Invoke-WebRequest against the repository URL. It appears to work fine, which is nice but also a pain as it indicates the problem is more complicated.

    PS C:\> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    PS C:\> $test = Invoke-WebRequest -UseBasicParsing "https://${progeturl}/nuget/${repository}/"
    Invoke-WebRequest: You must log in to issue this request because the anonymous user does not have the Feeds_ViewFeed privilege.
    PS C:\>
    PS C:\> $test = Invoke-WebRequest -UseBasicParsing "https://${progeturl}/nuget/${repository}/" -Credential $credential
    PS C:\> $test
    
    StatusCode        : 200
    StatusDescription : OK
    Content           : <?xml version="1.0" encoding="utf-8"?><service xmlns="http://www.w3.org/2007/app"><workspace><title xmlns="http://www.w3.org/2005/Atom">Default</title><collection
                        href="Packages"><title xmlns="http://…">
    RawContent        : HTTP/1.1 200 OK
                        Cache-Control: no-store, must-revalidate, no-cache, max-age=0
                        Pragma: no-cache
                        Server: Microsoft-IIS/10.0
                        X-ProGet-Version: 22.0.7.3
                        X-Powered-By: ASP.NET
                        Date: Sat, 24 Sep 2022 …
    Headers           : {[Cache-Control, System.String[]], [Pragma, System.String[]], [Server, System.String[]], [X-ProGet-Version, System.String[]]…}
    Images            : {}
    InputFields       : {}
    Links             : {}
    RawContentLength  : 273
    RelationLink      : {}
    
    
    PS C:\> echo $test.Content
    <?xml version="1.0" encoding="utf-8"?><service xmlns="http://www.w3.org/2007/app"><workspace><title xmlns="http://www.w3.org/2005/Atom">Default</title><collection href="Packages"><title xmlns="http://www.w3.org/2005/Atom">Packages</title></collection></workspace></service>
    

    I will attempt to use a tool like Wireshark or Fiddler to see what's going on.



Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation