In the context, I am creating an application that needs to download / unpack packages and their dependencies from arbitrary package sources (including the common gallery by default) and update these packages to the latest version upon request. There are no project.json files or similar files, they are all code driven. This is not a particularly difficult use case and does not require too much code in the v2 APIs.
However, in v3, I cannot figure out how to properly interact with the local package repository. For example, the FolderNuGetProject class, which I would think, lists all the packages on the disk in a specific place in FolderNuGetProject.GetInstalledPackagesAsync() just returns an empty enumerated . To make things more confusing, FolderNuGetProject.PackageExists() really returns if a package exists on disk, which means that GetInstalledPackagesAsync() and PackageExists() seem to be inconsistent.
No other NuGetProject derivatives are associated with the file system. Is there any other way to list packages that were installed in a specific folder? If I need to create my own NuGetProject (and I hope this does not happen), are there any methods that will help to parse the names of folders created by NuGet into package identifiers and their versions, or is this the only reliable way to get the identifier and version to open nuspec (and are there any methods for searching there)?
One interpretation of why this does not work, as I expect it, is that NuGetProject.GetInstalledPackagesAsync () is not really intended to install installed packages (i.e. those that were downloaded and unpacked), but rather those which were announced in any project system. For example, the BuildIntegratedNuGetProject class BuildIntegratedNuGetProject return package references for packages in project.json, regardless of their status on disk. This also explains why FolderNuGetProject simply returns an empty enumeration because there are no "declared" packages if you just look at the local repository.
TL DR: What is the best way to bypass the local package repository and get the packages and versions that are there?
(this was also issue # 2664 in the NuGet GitHub project, but was moved here on request)
source share