Skip to content
Snippets Groups Projects
Commit 8db5f09c authored by Bensong Liu's avatar Bensong Liu
Browse files

many bug fix, now openxt is able to work on the complete ControlPlane repo

parent 00433d25
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,10 @@ func ParseDependencies(csprojPath string) (dependencies []dependencyItem, err er
} else {
endPos := strings.IndexAny(hintPath, "/\\") // Maybe `/lib/` or `\lib\`
targetNetVer = hintPath[:endPos]
if dashPos := strings.Index(targetNetVer, "-"); dashPos != -1 {
// Someone use "lib/net40-full/..." in HintPath. Cut the tail.
targetNetVer = targetNetVer[:dashPos]
}
}
}
}
......
......@@ -10,7 +10,7 @@ import (
// Some options here. Would be improved in beta release.
const DEDUCT_PKGNAME_FROM_VARNAME = true
const USE_PROJECT_NETVER_INSTEAD_OF_HINTPATH_NETVER = false
const OPENXT_VERSION = "1.1-2"
const OPENXT_VERSION = "1.2"
func print_help_and_exit() {
println("Usage: openxt <subcommand> [options...]")
......
......@@ -39,9 +39,15 @@ func SyncPackages(nugetConfigPath, localRepoPath string, allDeps []dependencyIte
go func(index int, dep dependencyItem) {
defer func() {<-concurrencyLimitChan ; wg.Done()}()
log.Printf("[%v/%v] Begin downloading: %v:%v as var %v", index, len(depsToSync), dep.pkgName, dep.targetNetVer, dep.envName)
log.Println("nuget-download-package", dep.pkgName, dep.targetNetVer, localRepoPath, nugetConfigPath)
cmd := exec.Command("nuget-download-package", dep.pkgName, dep.targetNetVer, localRepoPath, nugetConfigPath)
realPkgName, realPkgVer := extractPostfixPkgVerFromPkgName(dep.pkgName)
if realPkgVer == "" {
// This is not a pkgname.pkgver format. Use targetNetVer to deduce.
realPkgVer = dep.targetNetVer
}
log.Println("EXEC: nuget-download-package", realPkgName, realPkgVer, localRepoPath, nugetConfigPath)
cmd := exec.Command("nuget-download-package", realPkgName, realPkgVer, localRepoPath, nugetConfigPath)
stdout, err := cmd.CombinedOutput()
log.Println(string(stdout))
// We can do nothing on failure. usually, if envName is NULL, we need not install it at all.
......
......@@ -231,7 +231,15 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
}
if packageVersion != "" {
// It should be a percise match here. However, someone in ControlPlane using PkgNewtonsoft_json_12.
// They only provide parts of the version number. It sucks.
thisPkgVersionIsOk = packageVersion == myVersionText
// That's why we use a prefix match here.
thisPkgVersionIsPossibleOk = strings.HasPrefix(myVersionText, packageVersion)
// Some noob is writing `windowsazure.servicebus:6.0.0.0` (should be 6.0.0).
// Let's also tolerate this. Fuck!
thisPkgVersionIsPossibleOk = strings.HasPrefix(packageVersion, myVersionText)
}
if thisPkgVersionIsOk {
......
......@@ -92,3 +92,39 @@ func depsDeduplicate(deps []dependencyItem) (resultDeps []dependencyItem) {
}
return
}
// Sometimes, they use `PkgMicrosoft_VisualStudio_Services_Release_Client_15_131_1` as var name,
// which would yeild Microsoft.VisualStudio.Services.Release.Client.15.131.1 as package name.
// This function could extract the real pkgName and pkgVer from bad pkgName.
func extractPostfixPkgVerFromPkgName(badPkgName string) (realPkgName, pkgVer string) {
// Reverse returns its argument string reversed rune-wise left to right.
strings_reverse := func (s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
}
splitedReversedStr := strings.Split(strings_reverse(badPkgName), ".")
for eleIndex, ele := range splitedReversedStr {
if strings.IndexFunc(ele, func(r rune) bool {return strings.IndexRune("0123456789", r) == -1}) == -1 {
// There's no non-number characters
// This element is version number.
} else {
pkgVer = strings_reverse(strings.Join(splitedReversedStr[:eleIndex], "."))
realPkgName = strings_reverse(strings.Join(splitedReversedStr[eleIndex:], "."))
break
}
}
if realPkgName == "" {
// This is not a valid PkgName.PkgVer format. Give up the guess.
// If there's no `.` in pkgVer, someone is using partial version number. Luckily, nuget-download-package can do this now.
// Example: microsoft.azure.webjobs:2 (PkgMicrosoft_Azure_Webjobs_2)
// Example: newtonsoft.json.12:net45
realPkgName = badPkgName
pkgVer = ""
}
return
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment