private string GetNuGetPackagePath()

in src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs [959:980]


        private string GetNuGetPackagePath(string packageId, string packageVersion, string packageRelativePath)
        {
            string relativePathToUse = String.IsNullOrEmpty(packageRelativePath)
                                            ? Path.Combine(packageId, packageVersion)
                                            : packageRelativePath.Replace('/', Path.DirectorySeparatorChar);

            string hashFileName = $"{packageId.ToLowerInvariant()}.{packageVersion.ToLowerInvariant()}.nupkg.sha512";

            foreach (var packagesFolder in _packageFolders)
            {
                string packageFullPath = Path.Combine(packagesFolder, relativePathToUse);

                // The proper way to check if a package is available is to look for the hash file, since that's the last
                // file written as a part of the restore process. If it's not there, it means something failed part way through.
                if (_fileExists(Path.Combine(packageFullPath, hashFileName)))
                {
                    return packageFullPath;
                }
            }

            throw new ExceptionFromResource(nameof(Strings.PackageFolderNotFound), packageId, packageVersion, string.Join(", ", _packageFolders));
        }