diff --git a/packageManager.go b/packageManager.go index 033ae901a8e8e546d861cdc837a3499b0263b9dc..9cdb6806cb20969fcd9f1bfb30d5897b8fe897a8 100644 --- a/packageManager.go +++ b/packageManager.go @@ -64,7 +64,7 @@ func SyncPackages(nugetConfigPath, localRepoPath string, allDeps []dependencyIte // | // The pkgName is case in-sensitive. func GetPackagePathFromName(localRepoPath, pkgName, targetNetVer string) (pkgPath string, err error) { - realPkgName, _ := extractPostfixPkgVerFromPkgName(pkgName) // pkgName with pkgVer would be discarded, and be guessed again. + realPkgName, pkgVerHint := extractPostfixPkgVerFromPkgName(pkgName) // pkgName with pkgVer should be discarded. guessBase := localRepoPath + string(os.PathSeparator) + strings.ToLower(realPkgName) files, err := ioutil.ReadDir(guessBase + string(os.PathSeparator)) if err != nil { @@ -74,6 +74,10 @@ func GetPackagePathFromName(localRepoPath, pkgName, targetNetVer string) (pkgPat maxVersion := "" for _, f := range files { if f.IsDir() && pathIsDir(guessBase + string(os.PathSeparator) + f.Name() + string(os.PathSeparator) + "lib" + string(os.PathSeparator) + targetNetVer) { + if strings.HasPrefix(maxVersion, pkgVerHint) && ! strings.HasPrefix(f.Name(), pkgVerHint) { + // If he matches pkgVerHint but you don't, you have no chance to be a candidate. + continue + } if version.CompareSimple(f.Name(), maxVersion) >= 0 { maxVersion = f.Name() }