{"record":{"id":"843b72c17dc36181","repo":"Unity-Technologies/UnityCsReference","slug":"assemblypath-cannot-be-null-or-empty","errorCode":null,"errorMessage":"assemblyPath cannot be null or empty","messagePattern":"assemblyPath cannot be null or empty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Scripting/ScriptCompilation/AssemblyBuilder.cs","lineNumber":71,"sourceCode":"        public int subtarget { get; set; }\n\n        public string[] defaultReferences => GetDefaultReferences(EditorCompilationInterface.Instance);\n        public string[] defaultDefines => GetDefaultDefines(EditorCompilationInterface.Instance);\n\n        private class BeeScriptCompilationState\n        {\n            public ScriptAssembly[] assemblies;\n            public ActiveBuild ActiveBuild;\n            public EditorCompilation editorCompilation;\n            public bool finishedCompiling;\n        }\n        private BeeScriptCompilationState activeBeeBuild;\n\n\n        public AssemblyBuilder(string assemblyPath, params string[] scriptPaths)\n        {\n            if (string.IsNullOrEmpty(assemblyPath))\n                throw new ArgumentException(\"assemblyPath cannot be null or empty\");\n\n            if (scriptPaths == null || scriptPaths.Length == 0)\n                throw new ArgumentException(\"scriptPaths cannot be null or empty\");\n\n            this.scriptPaths = scriptPaths;\n            this.assemblyPath = assemblyPath;\n\n            compilerOptions = new ScriptCompilerOptions();\n            flags = AssemblyBuilderFlags.None;\n            referencesOptions = ReferencesOptions.None;\n            buildTargetGroup = EditorUserBuildSettings.activeBuildTargetGroup;\n            buildTarget = EditorUserBuildSettings.activeBuildTarget;\n        }\n\n        public bool Build()\n        {\n            return Build(EditorCompilationInterface.Instance);\n        }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/ScriptCompilation/AssemblyBuilder.cs#L53-L89","documentation":"ArgumentException from the AssemblyBuilder constructor: assemblyPath must be a non-empty string. The builder needs a real output assembly path to compile to.","triggerScenarios":"Constructing new AssemblyBuilder(null, ...) or new AssemblyBuilder(\"\", ...) — passing a null or empty first argument.","commonSituations":"Programmatic assembly building where the output path is computed and comes back empty, or a copy-paste that drops the path argument.","solutions":["Compute and pass a valid absolute or relative assembly output path before constructing the builder.","Guard the call site: reject null/empty assemblyPath upstream."],"exampleFix":"// before\nvar b = new AssemblyBuilder(path, scripts);\n// after\nif (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));\nvar b = new AssemblyBuilder(path, scripts);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(assemblyPath))\n    throw new ArgumentException(\"assemblyPath is required\", nameof(assemblyPath));","typeGuard":"static bool IsValidAssemblyPath(string path) =>\n    !string.IsNullOrWhiteSpace(path) && path.IndexOfAny(Path.GetInvalidPathChars()) < 0;","tryCatchPattern":"try { var b = new AssemblyBuilder(assemblyPath, scripts); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"assemblyPath\"))\n{ /* recompute a valid output path and retry */ }","preventionTips":["Resolve the output assembly path from a known root before constructing the builder.","Never pass computed-but-unchecked path strings directly."],"tags":["script-compilation","validation","arguments"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}