diff --git a/main.go b/main.go index 7a4dd17d682254cc892320e68d0a15ff4f1b3860..6e1ed03c8ed57916074f26d61895bf8b332a7e04 100644 --- a/main.go +++ b/main.go @@ -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.4.1-1" +const OPENXT_VERSION = "1.4.1-2" func print_help_and_exit() { println("Usage: openxt <subcommand> [options...]") diff --git a/tools/csproj-to-5/main.go b/tools/csproj-to-5/main.go index 68f1d3a8935c8774e734dfe93867f11d179f9ea8..1f52bec82397cdd5e597291cfbe6b37d5b9095fc 100644 --- a/tools/csproj-to-5/main.go +++ b/tools/csproj-to-5/main.go @@ -4,6 +4,7 @@ import ( "io/ioutil" "log" "os" + "path/filepath" "strings" ) @@ -40,6 +41,39 @@ func stringReplaceOnceInsensitive(s, old, new string) string { } ///////////////////////////// utils END +// Send a warning if there's any "global.json" existing in parent path. +// BeginPoint could be a filename, or a directory. However, the leaf entry would be discarded (skipped)! +// +// Example: If beginPoint is `./program/minecraft/hmcl.jar`, then I'll search `./program/minecraft/*`, +// `./program/*`, `./*`, `./../*`, ... +// If beginPoint is `./program/minecraft`, then I'll search `./program/*`, `./*`, `./../*` ... +func warnGlobalJson(beginPoint string) { + // Make it abs path. + if !filepath.IsAbs(beginPoint) { + wd, err := os.Getwd() + if err != nil { + return + } + beginPoint = filepath.Join(wd, beginPoint) + } + + // Iterate + currPath := beginPoint + for { + // Go to parent, and exit the loop if we're already on root (`/` or `C:\`). + par := filepath.Dir(currPath) + if par == currPath { + break + } + currPath = par + + // Check if global.json exists in this level. + if _, err := os.Stat(filepath.Join(currPath, "global.json")); err == nil { + println("WARNING: Please consider remove " + currPath + string(os.PathSeparator) + "global.json . It may cause problem to your dotnet. ") + } + } +} + // This is a naive tool to convert CoreXT csproj file to dotnet 5 csproj file. // It should work on 99% well-formatted csproj file. // | @@ -54,7 +88,9 @@ func main() { content, err := ioutil.ReadFile(fname) panicErrorIfAny(err, "read file " + fname) - // Good luck for old MacOS! They use single \r as newline. + warnGlobalJson(fname) + + // May have problem here for old MacOS! They use single \r as newline. lines := strings.Split(strings.ReplaceAll(string(content), "\r\n", "\n"), "\n") resultTxt := "" removeEndOfTagInNextLine := "" // Empty value indicates no need to remove EOT.