{"record":{"id":"7455ce5c15d88ca4","repo":"CoplayDev/unity-mcp","slug":"source-directory-not-found-dir-fullname","errorCode":null,"errorMessage":"Source directory not found: {dir.FullName}","messagePattern":"Source directory not found: (.+?)","errorType":"exception","errorClass":"DirectoryNotFoundException","httpStatus":null,"severity":"error","filePath":"TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Utility/FileUtility.cs","lineNumber":57,"sourceCode":"                convertedPath = convertedPath.Substring(Constants.RootProjectPath.Length);\r\n            }\r\n            else\r\n            {\r\n                if (allowSymlinks && SymlinkUtil.FindSymlinkFolderRelative(convertedPath, out var symlinkPath))\r\n                    convertedPath = symlinkPath;\r\n            }\r\n\r\n            return convertedPath;\r\n        }\r\n\r\n        public static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)\r\n        {\r\n            // Get information about the source directory\r\n            var dir = new DirectoryInfo(sourceDir);\r\n\r\n            // Check if the source directory exists\r\n            if (!dir.Exists)\r\n                throw new DirectoryNotFoundException($\"Source directory not found: {dir.FullName}\");\r\n\r\n            // Cache directories before we start copying\r\n            DirectoryInfo[] dirs = dir.GetDirectories();\r\n\r\n            // Create the destination directory\r\n            Directory.CreateDirectory(destinationDir);\r\n\r\n            // Get the files in the source directory and copy to the destination directory\r\n            foreach (FileInfo file in dir.GetFiles())\r\n            {\r\n                string targetFilePath = Path.Combine(destinationDir, file.Name);\r\n                file.CopyTo(targetFilePath);\r\n            }\r\n\r\n            // If recursive and copying subdirectories, recursively call this method\r\n            if (recursive)\r\n            {\r\n                foreach (DirectoryInfo subDir in dirs)\r","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Utility/FileUtility.cs#L39-L75","documentation":"Thrown by FileUtility.CopyDirectory when the sourceDir passed to it does not exist on disk (DirectoryInfo.Exists is false). It is a guard before any file enumeration or copying begins, so no partial copy occurs. The exception message echoes dir.FullName for diagnosis.","triggerScenarios":"Calling CopyDirectory with a non-existent source path, a relative path resolved against the wrong working directory, or a path on a network mount that is unavailable. Also when a path contains typos, wrong drive letters, or trailing separators that change resolution.","commonSituations":"The build/upload pipeline computes a staging directory that was never created, a previous step cleaned temp dirs, or the path was hardcoded for a different machine. Common in CI where artifacts live in a different location than locally.","solutions":["Check Directory.Exists(sourceDir) before calling CopyDirectory and log the absolute path.","Ensure the directory-producing step runs (and succeeds) before the copy step.","Use Path.GetFullPath to resolve relative paths and verify against the expected location.","On network/removable drives, confirm the mount is present before copying."],"exampleFix":"// before\nFileUtility.CopyDirectory(stagingDir, destDir, recursive: true);\n// after\nif (!Directory.Exists(stagingDir)) throw new DirectoryNotFoundException(stagingDir);\nFileUtility.CopyDirectory(stagingDir, destDir, recursive: true);","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(sourceDir))\n    throw new DirectoryNotFoundException(sourceDir);","typeGuard":"static bool IsCopyableSource(string s) =>\n    !string.IsNullOrWhiteSpace(s) && Directory.Exists(s);","tryCatchPattern":"try { FileUtility.CopyDirectory(src, dst, recursive: true); }\ncatch (DirectoryNotFoundException ex) { Debug.LogError(ex.Message); }","preventionTips":["Check Directory.Exists before copying.","Use Path.GetFullPath to resolve and log absolute paths."],"tags":["csharp","unity","filesystem","asset-store","validation"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}