Skip to content
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

Verifying installed depencies after initial install throws exceptions for Artifactory Source Repositories and PSGalleryNuget dependencies #128

Open
ckolumbus opened this issue Mar 2, 2021 · 0 comments

Comments

@ckolumbus
Copy link

|## Problem:
I have a source repo on Articfactory that hosts my internal powershell modules but also serves as a proxy for the default PSGallery repository.

Configuration example

@{
    PSDependOptions = @{
        Target = '.\ps_modules'
        DependencyType = 'PSGalleryNuget'
        Source = 'https://artifactory.mylocal.domain/artifactory/api/nuget/myrepo/'
    }

    'InvokeBuild' = 'latest'
    'dotenv' = 'latest'

}

When I run two times behind each other

Invoke-PSDepend . -Install -Force -Verbose
Invoke-PSDepend . -Install -Force -Verbose

everything is fine with the first call, the dependencies get installed as expected. But the second time I get the following exception

VERBOSE: GET https://artifactory.mylocal.domain/artifactory/api/nuget/myrepo/Packages?$filter=Id eq 'InvokeBuild' and IsLatestVersion with 0-byte payload
Invoke-RestMethod : The remote server returned an error: (405) Method Not Allowed.
At C:\UserData\User\Documents\WindowsPowerShell\Modules\PSDepend\0.3.8\Private\Find-NugetPackage.ps1:47 char:5
+     Invoke-RestMethod $URI -Headers $headers |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

VERBOSE: You have the latest version of [InvokeBuild], with installed version [5.7.1] and PSGallery version []

same error for dotenv. The same call works if I use the default PSGallery url as source.

Solution:

The query URI is created in Find-NugetPackages.ps1, e.g. like

 $URI = "${PackageSourceUrl}Packages?`$filter=Id eq '$name' and IsLatestVersion

The problem with this is that Artifactory expects the search uri to be

 $URI = "${PackageSourceUrl}Packages()?`$filter=Id eq '$name' and IsLatestVersion

mind the () behind Packages. AFAIK this is the define "standard" (if such a thing exists) but most of the nuget servers on the internet accept uris without the () as well. Not so artifactory.

Proposal

add () to the search URI creation. According to my tests this works with nuget.org and powershellgallery.com, so I assume that any other nuget server will bi accpting the braces, too. And Artifactory is also happy :-)

PR is on the way!

@ckolumbus ckolumbus changed the title Verifying installed depencies after initial install fails for Artifactory Source repo and PSGalleryNuget dependencies Verifying installed depencies after initial install throws exceptions for Artifactory Source Repositories and PSGalleryNuget dependencies Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant