From ebdf250d928e397a5763fd39fc4918870ff1859e Mon Sep 17 00:00:00 2001 From: Recolic K <bensl@microsoft.com> Date: Thu, 13 May 2021 14:51:00 +0800 Subject: [PATCH] use pkgVerHint while generating pkgPath --- packageManager.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packageManager.go b/packageManager.go index 033ae90..9cdb680 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() } -- GitLab