{"record":{"id":"ad2e0d37088d4b39","repo":"huiyadanli/RevokeMsgPatcher","slug":"no-valid-version-directories-found-in-searchdire","errorCode":null,"errorMessage":"No valid version directories found in: {searchDirectory}","messagePattern":"No valid version directories found in: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"RevokeMsgPatcher/Model/TargetInfo.cs","lineNumber":76,"sourceCode":"\n                foreach (var directory in directories)\n                {\n                    var dirName = Path.GetFileName(directory);\n\n                    // 检查是否包含至少两个点\n                    if (dirName.Count(c => c == '.') >= 2)\n                    {\n                        // 尝试解析为版本号\n                        if (Version.TryParse(dirName.Replace(\"-\",\".\"), out Version version))\n                        {\n                            validVersions.Add(new Tuple<string, Version>(dirName, version));\n                        }\n                    }\n                }\n\n                if (validVersions.Count == 0)\n                {\n                    throw new InvalidOperationException($\"No valid version directories found in: {searchDirectory}\");\n                }\n\n                // 找到版本号最大的目录\n                var maxVersionDir = validVersions.OrderByDescending(v => v.Item2).First().Item1;\n\n                // 构建完整路径\n                var fullRelativePath = RelativePath.Replace(\"{version}\", maxVersionDir);\n                return Path.Combine(installPath, fullRelativePath);\n            }\n            else\n            {\n                return Path.Combine(installPath, RelativePath);\n            }\n        }\n    }\n}\n","sourceCodeStart":58,"sourceCodeEnd":93,"githubUrl":"https://github.com/huiyadanli/RevokeMsgPatcher/blob/89cbbb3f0cc896d5d092de0199a635c5c39944b6/RevokeMsgPatcher/Model/TargetInfo.cs#L58-L93","documentation":"TargetInfo.GetAbsolutePath resolves a '{version}' placeholder by scanning subdirectories of a search directory and keeping those whose name has >= 2 dots and parses as a Version. If none qualify, it throws InvalidOperationException listing the search directory.","triggerScenarios":"A TargetInfo.RelativePath containing '{version}' but the corresponding directory has no version-named subdirs (e.g. the app's versions folder is empty, or names have fewer than 2 dots or are non-parseable like a single-segment number).","commonSituations":"Wrong install path; app stores versions in a sibling directory that does not match the >=2-dot rule; a fresh install whose versions subfolder has not been populated yet.","solutions":["Point at the real install path that contains the versions subfolder.","Confirm the version directory name has >= 2 dots and parses (e.g. 9.9.9, or 3.2.1-5 after the '-'->'.' normalization).","If the app uses a non-standard version dir scheme, the TargetInfo config or the >=2-dot rule needs updating."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"string searchDirectory = Path.Combine(installPath, prefixPath);\nif (!Directory.Exists(searchDirectory))\n{\n    return \"\"; // matches GetAbsolutePath's own empty-return for a missing dir\n}\nbool hasVersionDir = Directory.GetDirectories(searchDirectory)\n    .Any(d => Path.GetFileName(d).Count(c => c == '.') >= 2);\nif (!hasVersionDir)\n{\n    MessageBox.Show($\"{searchDirectory} 下未找到有效的版本目录。\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the install path contains a populated versions subfolder before patching.","Ensure version directory names have >= 2 dots and parse as System.Version.","Wrap GetAbsolutePath in try/catch(InvalidOperationException) to degrade gracefully."],"tags":["path","version-detection","targetinfo"],"backgroundTag":null,"analyzedSha":"89cbbb3f0cc896d5d092de0199a635c5c39944b6","analyzedAt":"2026-08-13T10:37:37.073Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}