Possible Nuget API 2.0.0 Bug (LinqPad 5)
My company is running a pretty old nuget server that can't be upgraded easily. This server (running Klondike 2.0.0) only supports the nuget 2.0.0 API. For a long time I've had a lot of problems installing packages from this server in LinqPad. Every time I try I'm getting a 404 response from the server but no other useful feedback. Today I just happened to notice when I clicked the "Add specific version to query" button that I got a more detailed error message that included the URL it was trying to reach.
The URL being requested looks like this (with placeholder values for the server and package name):
http://nuget.server/api/odata/FindPackagesById%28%29?id=%27Package.Name%27&semVerLevel=2.0.0&$skip=100
After some tinkering in Postman, I found that to make it work I had to change FindPackagesById%28%29
to FindPackagesById()
. For whatever reason it really doesn't want those parenthesis URL encoded. It's possible this could be a problem with the server implementation but all our other tooling interacts with this server just fine.
For this particular query the &$skip=100
looks a little a suspect to me as well because it seems a bit arbitrary to skip the first 100 versions and the extra $ in there makes me think it's getting added in some strange way outside how the other arguments are being appended.
My gut feeling is that there's something not quite right in the code path to build queries against the 2.0 nuget API. Most people aren't using 8 year old unmaintained nuget servers though so this code probably isn't being exercised a ton. I haven't tried the new LinqPad to see if this behavior is any different.
Please let me know if there's any additional information I could provide that might be helpful.
Comments
Are you using the legacy search engine? (Go to NuGet Package Manager, click Settings, then Advanced)
That was embarrassingly easy to fix. I don't know how I never tried that. It's not like the screen is overflowing with options. Oof. Thanks for the quick and easy fix.