{"record":{"id":"f9c87a9a19f4178a","repo":"dotnet/runtime","slug":"error-output-file-name-exceeds-d-characters","errorCode":null,"errorMessage":"\nError: Output file name exceeds %d characters\n","messagePattern":"\nError: Output file name exceeds (.+?) characters\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/ilasm/main.cpp","lineNumber":402,"sourceCode":"                        pAsm->m_wzKeySourceName = pStr;\n                    }\n                    else if (!_stricmp(szOpt, \"INC\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        for(pStr++; *pStr == W(' '); pStr++); //skip the blanks\n                        if(u16_strlen(pStr)==0) goto InvalidOption; //if no file name\n                        wzIncludePath = pStr;\n                    }\n                    else if (!_stricmp(szOpt, \"OUT\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        for(pStr++; *pStr == W(' '); pStr++); //skip the blanks\n                        if(u16_strlen(pStr)==0) goto InvalidOption; //if no file name\n                        if(u16_strlen(pStr) >= MAX_FILENAME_LENGTH)\n                        {\n                            fprintf(stderr,\"\\nError: Output file name exceeds %d characters\\n\",MAX_FILENAME_LENGTH-1);\n                            goto ErrorExit;\n                        }\n                        wcscpy_s(wzOutputFilename,MAX_FILENAME_LENGTH,pStr);\n                    }\n                    else if (!_stricmp(szOpt, \"MDV\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        for(pStr++; *pStr == W(' '); pStr++); //skip the blanks\n                        if(u16_strlen(pStr)==0) goto InvalidOption; //if no version string\n                        pAsm->m_wzMetadataVersion = pStr;\n                    }\n                    else if (!_stricmp(szOpt, \"MSV\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        for(pStr++; *pStr == W(' '); pStr++); //skip the blanks\n                        if(u16_strlen(pStr)==0) goto InvalidOption; //if no version","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/ilasm/main.cpp#L384-L420","documentation":"ilasm rejects an output path longer than MAX_FILENAME_LENGTH-1 (2047 chars, defined in assembler.h:33). The `/OUT=<file>` handler (main.cpp:400) measures the wide-string length; at or above the limit it prints this and goes to ErrorExit before copying into the wzOutputFilename buffer.","triggerScenarios":"Passing `/OUT=` with a path >= 2048 characters; an environment where the output path is composed from a very long build directory tree.","commonSituations":"Deeply nested CI workspace paths combined with long assembly names; a typo injecting thousands of characters (e.g. a repeated segment).","solutions":["Shorten the output path: use a shorter directory or filename.","Set the output to a relative name in the current directory.","Move the build to a shallower workspace root."],"exampleFix":"// before\nilasm /OUT=/very/long/.../repeated/.../MyComponent.dll foo.il\n// after\nilasm /OUT=MyComponent.dll foo.il","handlingStrategy":"validation","validationCode":"// Validate the /OUT path length before spawning ilasm.\nconst MAX = 2048 - 1; // MAX_FILENAME_LENGTH-1\nif (outPath.length >= MAX) throw new Error('Output path too long for ilasm: ' + outPath.length);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep build workspace paths shallow.","Use relative output names where possible.","Assert path lengths in build scripts before invoking ilasm."],"tags":["ilasm","cli","filename","path-length"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}