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

Can't list packages from BaGet #455

Open
zhaparoff opened this issue Jan 30, 2020 · 4 comments · Fixed by #465
Open

Can't list packages from BaGet #455

zhaparoff opened this issue Jan 30, 2020 · 4 comments · Fixed by #465

Comments

@zhaparoff
Copy link

Describe the bug

I'm trying to get a list of versions of one package in my local feed (basically to clean up pre-release ones) but with no luck.

I've tried so far:

  1. Nuget CLI.
  2. Console app, using BaGet SDK.

Both do not work.

To Reproduce

  1. Run command
    nuget.exe list [PackageName] -AllVersions -Source "http://[bageturl]/v3/index.json"

OR

2.1. Create a console app with code from SDK documentation:

var packageName = [PackageName];
var client = new NuGetClient("http://[bageturl]/v3/index.json");

// Find the metadata for all versions of a package.
var items = await client.GetPackageMetadataAsync(packageName);
if (!items.Any())
{
    Console.WriteLine($"Package '{packageName}' does not exist");
    return;
}

foreach (var metadata in items)
{
    Console.WriteLine($"Version: {metadata.Version}");
    Console.WriteLine($"Listed: {metadata.Listed}");
    Console.WriteLine($"Tags: {metadata.Tags}");
    Console.WriteLine($"Description: {metadata.Description}");
}

2.2. Run it.

Expected behavior

  1. A list of packages is returned

  2. List of '[PackageName]' package metadata is printed to console.

Actual behavior

  1. No packages are returned. The following warning is displayed:

WARNING: This version of nuget.exe does not support listing packages from package source 'http://[bageturl]/v3/index.json'.

  1. Code throws an exception at line:
    var items = await client.GetPackageMetadataAsync(packageName);

System.ArgumentNullException
HResult=0x80004003
Message=Value cannot be null. (Parameter 'catalogUrl')
Source=BaGet.Protocol
StackTrace:
at BaGet.Protocol.Internal.RawCatalogClient..ctor(HttpClient httpClient, String catalogUrl)
at BaGet.Protocol.NuGetClientFactory.d__111.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at BaGet.Protocol.NuGetClient.<GetPackageMetadataAsync>d__8.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at BaGet.Tools.Program.

d__0.MoveNext() in C:_Work\Code\Z\Temp\BaGet.Tools\Program.cs:line 16

This exception was originally thrown at this call stack:
BaGet.Protocol.Internal.RawCatalogClient.RawCatalogClient(System.Net.Http.HttpClient, string)
BaGet.Protocol.NuGetClientFactory.GetClientAsync(System.Func<BaGet.Protocol.NuGetClientFactory.NuGetClients, T>, System.Threading.CancellationToken)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
BaGet.Protocol.NuGetClient.GetPackageMetadataAsync(string, System.Threading.CancellationToken)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
...
[Call Stack Truncated]

Additional context

BaGet:

  • built from the 62e28b9
  • .NET Core SDK v3.1.101
  • Visual Studio Pro 2019 v16.4.3
  • deployed to IIS 8.5 @ Windows Server 2012 R2 (6.2 build 9200)

Sample code is built with the same .NET Core and VS versions.
Using latest BaGet.Protocol package (https://www.nuget.org/packages/BaGet.Protocol/0.2.0-preview1)

Nuget v5.4.0

@loic-sharma
Copy link
Owner

loic-sharma commented Feb 8, 2020

  1. nuget list won't work on BaGet until the legacy NuGet V2 API is supported. This is tracked by Support v2 APIs #43
  2. Is a bug. I will fix that ASAP, thank you for reporting! I've created BaGet.Protocol doesn't work on BaGet server #464 to track this item

@loic-sharma
Copy link
Owner

loic-sharma commented Feb 8, 2020

Okay problem 2 will be fixed by the next release! By the way, here's the easiest way to get a the list of versions:

var packageName = [PackageName];
var client = new NuGetClient("http://[bageturl]/v3/index.json");

var versions = await client.ListPackageVersionsAsync(packageName, cancellationToken);

loic-sharma added a commit that referenced this issue Feb 8, 2020
@loic-sharma loic-sharma reopened this Feb 8, 2020
@loic-sharma
Copy link
Owner

Reopening this as I haven't tagged a release with the fix yet.

@zhaparoff
Copy link
Author

It is working fine for me with 0.3.0-preview3. Thanks!

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.

2 participants