public IEnumerable<VersionInfo> GetDLLVersions(string binDirectoryPath, string pattern)
        {
            System.Console.WriteLine(binDirectoryPath);
            // find all DLLs in bin folder that match the given filter
            string notSitecorePattern = "^(?!(Sitecore)).*(.dll)$";
            var matches = Directory.GetFiles(binDirectoryPath)
                            .Select(path => Path.GetFileName(path))
                            .Where(path => Regex.Match(path, (!String.IsNullOrWhiteSpace(pattern) ? pattern : notSitecorePattern), 
                                                       RegexOptions.IgnoreCase).Success);

            var dllVersionList = new List<VersionInfo>();
            // find the version numbers of these DLLs
            foreach(string file in matches)
            {
                string filename = Assembly.LoadFrom(binDirectoryPath + file).GetName().Name;

                FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(binDirectoryPath + file);
                string version = fvi.FileVersion;
                Version ver = new Version(fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart);

                //Version ver = Assembly.LoadFrom(binDirectoryPath + file).GetName().Version;

                VersionInfo dllVersion = new VersionInfo() { Name = filename, VersionNumber = ver };
                dllVersionList.Add(dllVersion);
            }

            return dllVersionList;
        }
        private IPackage FindMatchingPackageVersion(IEnumerable<IPackage> packages, VersionInfo dllVersionInfo)
        {
            IPackage matchingPackage = packages.Where(package => package.Version.Version.Equals(dllVersionInfo.VersionNumber)).FirstOrDefault();
            if (matchingPackage == null)
            {
                // Major, Minor, Build

                Version buildVersionMatch = new Version(dllVersionInfo.VersionNumber.Major,
                                                 dllVersionInfo.VersionNumber.Minor,
                                                 dllVersionInfo.VersionNumber.Build, 0);

                matchingPackage = packages.Where(package => package.Version.Version.Equals(buildVersionMatch)).FirstOrDefault();

                if (matchingPackage == null)
                {
                    // Major, Minor, BuildDigit1 (i.e 5.2.30706 becomes 5.2.3)
                    int firstDigitBuildNumber = Math.Abs(dllVersionInfo.VersionNumber.Build);
                    while (firstDigitBuildNumber >= 10)
                        firstDigitBuildNumber /= 10;

                    Version firstDigitiBuildVersionMatch = new Version(dllVersionInfo.VersionNumber.Major,
                                                     dllVersionInfo.VersionNumber.Minor,
                                                     firstDigitBuildNumber, 0);

                    matchingPackage = packages.Where(package => package.Version.Version.Equals(firstDigitiBuildVersionMatch)).FirstOrDefault();

                    if (matchingPackage == null)
                    {

                        // Major, Minor
                        Version minorVersionMatch = new Version(dllVersionInfo.VersionNumber.Major,
                                                         dllVersionInfo.VersionNumber.Minor, 0, 0);

                        matchingPackage = packages.Where(package => package.Version.Version.Equals(minorVersionMatch)).FirstOrDefault();

                        if (matchingPackage == null)
                        {
                            // Major
                            Version majorVersionMatch = new Version(dllVersionInfo.VersionNumber.Major, 0, 0, 0);

                            matchingPackage = packages.Where(package => package.Version.Version.Equals(majorVersionMatch)).FirstOrDefault();
                        }
                    }
                }
            }

            return matchingPackage;
        }
        /// <summary>
        /// Searches for the package on nuget.org (the public Nuget repository)
        /// </summary>
        /// <param name="dllVersionInfo"></param>
        public PackageSearchResult SearchForPackage(VersionInfo dllVersionInfo)
        {
            string packageID = dllVersionInfo.Name;

            // http://blog.nuget.org/20130520/Play-with-packages.html
            //Connect to the official package repository
            IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");

            //Get the list of all NuGet packages with the ID provided
            List<IPackage> packages = repo.FindPackagesById(packageID).ToList();
            if (!packages.Any())
            {
                // error package not found
                Console.WriteLine("- Package Not Found: " + dllVersionInfo.Name);
                return new PackageSearchResult()
                            {
                                Issue = new DLLIssueInfo() { Issue = DLLIssue.NoCorrespondingPackageFound, DLLInSitecore = dllVersionInfo }
                            };
            }

            IPackage matchingPackage = this.FindMatchingPackageVersion(packages, dllVersionInfo);
            if (matchingPackage == null) // || IsNotCompleteVersion) - DotNetOpenAuth issue
            {
                Console.WriteLine("--- Version Not Found: " + dllVersionInfo.Name + ", " + dllVersionInfo.VersionNumber.ToString());

                return new PackageSearchResult()
                {
                    Issue = new DLLIssueInfo() { Issue = DLLIssue.NoCorrespondingVersionForPackageFound, DLLInSitecore = dllVersionInfo }
                };
            }

            
            var nugetPackageInfo = CreateNugetPackageInfoFromIPackage(matchingPackage);
            Console.WriteLine("PACKAGE FOUND: " + nugetPackageInfo.Info.Name + ", " + nugetPackageInfo.Info.VersionNumber.ToString());
            // sholmesby: HACK for single DLL test
            nugetPackageInfo.DLLsInPackage.Add(dllVersionInfo);
            return new PackageSearchResult()
            {
                NugetPackage = nugetPackageInfo
            }; 
        }