2
votes

The flowing code has been pushed to an Azure DevOps Artifacts Feed:

schily-cdrtools

Pushing the nuget package and downloading work without issues using nuget.exe:

nuget.exe push -Source "cdrtools-artifacts" -ApiKey AzureDevOps schily-cdrtools.3.2.1.nupkg

nuget.exe install -Source "cdrtools-artifacts" schily-cdrtools 

However, attempting to register this source with Chocolatey results in a 404 error using either a v2 or v3 nuget registration:

choco source add -n=schily-artifacts `
>>    -s="https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json" `
>>    -u="xxxxxxxx" -p="xxxxxxxxxxx"

 Error retrieving packages from source 'https://flapjacks.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json':
 The remote server returned an error: (404) Not Found.
 schily-cdrtools not installed. The package was not found with the source(s) listed.
 Source(s): 'https://flapjacks.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json'
 NOTE: When you specify explicit sources, it overrides default sources.
 If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
 Please see https://chocolatey.org/docs/troubleshooting for more
 assistance.

...and the same 404 error when using v2:

choco source add -n=schily-artifacts `
>>    -s="https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2" `
>>    -u="xxxxxxxx" -p="xxxxxxx"

Trying to list with the v2 registration comes up with no packages found, however when running choco list with the v3 it comes back with a 404 error.

Finally, trying with Install-Package failes with a credentials issue:

Install-Package schily-cdrtools
WARNING: Cannot access 'https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v3/index.json'. Are you missing 'Credential' parameter in the cmdlet?

Install-Package : No match was found for the specified search criteria and package name 'schily-cdrtools'. Try Get-Packa
geSource to see all available registered package sources.
At line:1 char:1
+ Install-Package schily-cdrtools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.PowerShel\u2026lets.InstallPackage:InstallPackage) [Install-Package
], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Any ideas no what I'm missing?

I've been using the following as a guide:

https://blog.pauby.com/post/chocolatey-repository-using-azure-devops-artifacts-feed/

2

2 Answers

1
votes

Cannot access Chocolatey package from Azure DevOps Artifact Feed

I could not reproduce this issue after created a sample based on the steps in that guide. But I would like provide some troubleshooting to you:

  1. Check your Chocolatey version, mine is Chocolatey v0.10.15.
  2. Use PAT instead of password when you add Chocolatey Azure DevOps Feed named source.
  3. Run the command line with Administrator.
  4. The command line should be complete and does not require a branch, like:

    choco source add -n=MyCustomFeed -s="https://pkgs.dev.azure.com/<MyOrgName>/_packaging/<FeedName>/nuget/v2" -u="MyAccount.com" -p="PAT"
    

My Test Result:

enter image description here

enter image description here

Hope this helps.

0
votes

The PackageManagement cmdlets are broken currently so using Install-Package without the -Credential parameter will fail. You need to add the -Credential parameter to all of the PackageManagement cmdlets for them to work.

If I run (exactly):

choco source add -n=schily-artifacts -s="https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2" -u="xxxxxxxx" -p="xxxxxxxxxxx"

Then I get:

Chocolatey v0.10.15
Added schily-artifacts - https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2 (Priority 0)

Chocolatey doesn't validate the feed until you use it:

choco list --source=schily-artifacts
Chocolatey v0.10.15
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
[NuGet] Not able to contact source 'https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2'. Error was The remote server returned an error: (401) Unauthorized.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
[NuGet] Not able to contact source 'https://flapjacks.pkgs.visualstudio.com/_packaging/schily-artifacts/nuget/v2'. Error was The remote server returned an error: (401) Unauthorized.
0 packages found.

Which is what I'd expect (as the credentials are invalid). So I'm not sure where your errors are coming from when adding the source.