{"record":{"id":"c22e2fc4c7d57703","repo":"Unity-Technologies/UnityCsReference","slug":"scriptpaths-cannot-be-null-or-empty","errorCode":null,"errorMessage":"scriptPaths cannot be null or empty","messagePattern":"scriptPaths cannot be null or empty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Scripting/ScriptCompilation/AssemblyBuilder.cs","lineNumber":74,"sourceCode":"        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        }\n\n        internal bool Build(EditorCompilation editorCompilation)\n        {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/ScriptCompilation/AssemblyBuilder.cs#L56-L92","documentation":"ArgumentException from the AssemblyBuilder constructor: the scriptPaths params array must be non-null and non-empty. The builder cannot compile with zero source files.","triggerScenarios":"Constructing new AssemblyBuilder(path) with no script files, or passing a null array / empty array as scriptPaths.","commonSituations":"Building an assembly from a glob that matched nothing, or omitting the script paths argument.","solutions":["Ensure at least one source file is collected before constructing the builder.","Null/length-check the scriptPaths array at the call site."],"exampleFix":"// before\nvar b = new AssemblyBuilder(path, scripts);\n// after\nif (scripts == null || scripts.Length == 0) throw new ArgumentException(\"No scripts to compile\", nameof(scripts));\nvar b = new AssemblyBuilder(path, scripts);","handlingStrategy":"validation","validationCode":"if (scriptPaths == null || scriptPaths.Length == 0)\n    throw new ArgumentException(\"At least one script path is required\", nameof(scriptPaths));","typeGuard":"static bool HasScripts(string[] paths) => paths != null && paths.Length > 0;","tryCatchPattern":"try { var b = new AssemblyBuilder(assemblyPath, scripts); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"scriptPaths\"))\n{ /* collect actual source files and retry */ }","preventionTips":["Verify your file glob returned matches before building.","Treat an empty source set as a configuration error, not a no-op."],"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"}