Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

PackagesODataController removes filter when searching while specifying targetFramework #47

Open
romerod opened this issue Sep 7, 2017 · 3 comments

Comments

@romerod
Copy link

romerod commented Sep 7, 2017

VS2017 package manager sends the following query to a nuget repository:

Search()?$filter=IsLatestVersion&searchTerm=%27%27&targetFramework=%27net462%27&includePrerelease=false&$skip=0&$top=26

In the following code in the PackagesODataController removes the filter which results in an almost empty result list.

if (!string.IsNullOrWhiteSpace(targetFramework))
            {
                targetFrameworks = targetFramework.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Distinct();
                options = RemoveFilter(options);
            }

Is there any reason for this?

@chriseldredge
Copy link

Yes, there's a reason. The filter that is being stripped is attempting to select only the latest version of a package, but when a specific target framework version is included in the query criteria, this can produce an empty result.

Consider the case of a package that released version 1.0, which supported .net 3.5. Then, two years later they dropped support for .net 3.5 and only support .net 4.5.

If a client searches for packages compatible with .net 3.5, they'd want to see version 1.0 of that package. The "latest version" criteria would prevent that from happening.

@jweber
Copy link

jweber commented Oct 11, 2017

We're seeing this same problem. When the filter is removed it causes all versions of the each package to be returned by the Search endpoint in the controller.

In our case browsing the NuGet repository in Visual Studio results in only one package being displayed. This is since Visual Studio is only asking for the first 26 results. The first 26 results from the PackagesODataController returned 26 different versions of the same package.

jweber added a commit to jweber/NuGet.Lucene that referenced this issue Oct 11, 2017
jweber added a commit to jweber/NuGet.Lucene that referenced this issue Oct 11, 2017
@chriseldredge
Copy link

This is a frustrating problem. These additional checks were added to work around a previous version of the NuGet addon for Visual Studio, and now it sounds like the behavior has changed once again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants