{"record":{"id":"3124ccea6a8724fe","repo":"dotnet/wpf","slug":"xml-file-not-found","errorCode":null,"errorMessage":"XML file not found","messagePattern":"XML file not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/ResourceGenerator.cs","lineNumber":186,"sourceCode":"            //\n            // Handle \"-h\" option.\n            //\n\n            if (parsedArgs.help)\n            {\n                Usage();\n                resourceModel = null;\n                return;\n            }\n\n\n            //\n            // Check that files exist\n            //\n\n            if (!File.Exists(parsedArgs.xmlFile))\n            {\n                throw new FileNotFoundException(\"XML file not found\", parsedArgs.xmlFile);\n            }\n\n            if (!File.Exists(parsedArgs.xsdFile))\n            {\n                throw new FileNotFoundException(\"Schema not found\", parsedArgs.xsdFile);\n            }\n\n            //\n            // Load the XML file and create the resource model from it\n            //\n\n            XmlDocument document = LoadDocument(parsedArgs.xmlFile, parsedArgs.xsdFile);\n            resourceModel = new ResourceModel(document, parsedArgs.outputDirectory);\n        }\n\n        public static void ReportArgumentError(string message)\n        {\n            Usage();","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/ResourceGenerator.cs#L168-L204","documentation":"ResourceGenerator.ProcessArgs validates its command-line inputs after parsing and throws FileNotFoundException when the XML data file supplied via parsedArgs.xmlFile does not exist on disk. This is a fail-fast check so the generator stops before attempting to load a missing resource model.","triggerScenarios":"Running the ResourceGenerator tool with a path to the XML file that does not exist: misspelled file name, wrong working directory, relative path resolved from an unexpected location, or the file was deleted/moved before the run.","commonSituations":"Build scripts or MSBuild targets invoking the tool from a different working directory than expected; CI checkouts missing generated or checked-in XML data files; typos in the XML path argument.","solutions":["Verify the path passed for the XML file exists: run File.Exists / ls on the exact path.","Use an absolute path in the build script to avoid working-directory surprises.","Fix the argument in the invoking script/target, or check out/restore the missing XML file.","Check case sensitivity of the file name on Linux-style filesystems."],"exampleFix":"// before\ncsp ResourceGenerator model.xml\n// (model.xml not in current dir)\n// after\ncsp ResourceGenerator $(MSBuildProjectDirectory)\\Resources\\model.xml","handlingStrategy":"validation","validationCode":"if (!File.Exists(xmlPath))\n    throw new FileNotFoundException($\"XML data file missing: {Path.GetFullPath(xmlPath)}\");","typeGuard":null,"tryCatchPattern":"try { generator.ProcessArgs(args); }\ncatch (FileNotFoundException ex) when (ex.FileName == xmlPath) { Console.Error.WriteLine($\"XML file not found: {ex.FileName}\"); return 2; }","preventionTips":["Use absolute paths in build scripts and CI.","Check File.Exists on all inputs before invoking the generator.","Ensure the XML data file is committed/generated before the tool runs."],"tags":["filenotfound","cli","codegen","input-validation"],"backgroundTag":"file-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}