{"record":{"id":"c6e7d1e6e6dfe868","repo":"CoplayDev/unity-mcp","slug":"folder-must-contain-editor-and-runtime-subfolders","errorCode":null,"errorMessage":"Folder must contain Editor and Runtime subfolders.","messagePattern":"Folder must contain Editor and Runtime subfolders\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Services/PackageDeploymentService.cs","lineNumber":245,"sourceCode":"            if (!Directory.Exists(sourcePath))\n            {\n                if (throwOnError)\n                {\n                    throw new ArgumentException(\"Selected folder does not exist.\");\n                }\n\n                return \"Selected folder does not exist.\";\n            }\n\n            bool hasEditor = Directory.Exists(Path.Combine(sourcePath, \"Editor\"));\n            bool hasRuntime = Directory.Exists(Path.Combine(sourcePath, \"Runtime\"));\n\n            if (!hasEditor || !hasRuntime)\n            {\n                string message = \"Folder must contain Editor and Runtime subfolders.\";\n                if (throwOnError)\n                {\n                    throw new ArgumentException(message);\n                }\n\n                return message;\n            }\n\n            return null;\n        }\n\n        private static string MakeAbsolute(string assetPath)\n        {\n            assetPath = assetPath.Replace('\\\\', '/');\n\n            if (assetPath.StartsWith(\"Assets/\", StringComparison.OrdinalIgnoreCase))\n            {\n                return Path.GetFullPath(Path.Combine(Application.dataPath, \"..\", assetPath));\n            }\n\n            if (assetPath.StartsWith(\"Packages/\", StringComparison.OrdinalIgnoreCase))","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Services/PackageDeploymentService.cs#L227-L263","documentation":"Thrown by ValidateSource when the source folder exists but lacks one or both required 'Editor' and 'Runtime' subdirectories. MCP for Unity packages follow a UPM-style layout that needs both; pointing at the wrong folder (e.g. the repo root) fails this check.","triggerScenarios":"sourcePath points at the repository root, a flat package, or a sibling folder that has no Editor/ or Runtime/ subfolder; only one of the two is present.","commonSituations":"User selected the repo root instead of the MCPForUnity/ package folder; a custom package built without the standard layout; selected the Editor folder itself instead of its parent.","solutions":["Point sourcePath at the package root that contains both 'Editor' and 'Runtime' subfolders (e.g. the MCPForUnity/ directory).","If building a custom package, create both Editor/ and Runtime/ subfolders before deploying.","Do not select the Editor/ folder itself — select its parent."],"exampleFix":"// before — selected the repo root, which has no Editor/ + Runtime/\nValidateSource(repoRoot, throwOnError: true); // throws\n\n// after — select the package folder containing both\nValidateSource(Path.Combine(repoRoot, \"MCPForUnity\"), throwOnError: true);","handlingStrategy":"validation","validationCode":"bool hasEditor = Directory.Exists(Path.Combine(sourcePath, \"Editor\"));\nbool hasRuntime = Directory.Exists(Path.Combine(sourcePath, \"Runtime\"));\nif (!hasEditor || !hasRuntime)\n    return ErrorResponse(\"Source folder must contain Editor/ and Runtime/ subfolders.\");","typeGuard":"static bool HasPackageLayout(string p)\n    => Directory.Exists(Path.Combine(p, \"Editor\"))\n       && Directory.Exists(Path.Combine(p, \"Runtime\"));","tryCatchPattern":"try { ValidateSource(sourcePath, throwOnError: true); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Editor and Runtime\"))\n{ /* point at the package root that contains both subfolders */ }","preventionTips":["Select the package root containing both Editor/ and Runtime/, not the repo root or the Editor folder itself.","For custom packages, create both subfolders before deploying.","Use ValidateSource(throwOnError:false) to surface the structural error as a message."],"tags":["package-deployment","validation","folder-structure"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}