Unity-Technologies/UnityCsReference · error · Exception
Required property 'name' not set
Error message
Required property 'name' not set
What it means
Thrown by CustomScriptAssembly.ValidateFields: an assembly definition (.asmdef) is valid only if its 'name' field is a non-empty string. A missing or blank name is rejected before the assembly is registered.
Source
Thrown at Editor/Mono/Scripting/ScriptCompilation/CustomScriptAssembly.cs:124
public static CustomScriptAssemblyData FromJsonNoFieldValidation(string json)
{
var assemblyData = new CustomScriptAssemblyWithLegacyData();
assemblyData.autoReferenced = true;
UnityEngine.JsonUtility.FromJsonOverwrite(json, assemblyData);
UpdateRenamedReferences(assemblyData);
assemblyData.UpdateLegacyData();
if (assemblyData == null)
throw new System.Exception("Json file does not contain an assembly definition");
return assemblyData;
}
public void ValidateFields()
{
if (string.IsNullOrEmpty(name))
throw new System.Exception("Required property 'name' not set");
if ((excludePlatforms != null && excludePlatforms.Length > 0) &&
(includePlatforms != null && includePlatforms.Length > 0))
throw new System.Exception("Both 'excludePlatforms' and 'includePlatforms' are set.");
if (autoReferenced && UnityCodeGenHelpers.IsCodeGen(name))
{
throw new Exception($"Assembly '{name}' is a CodeGen assembly and cannot be Auto Referenced");
}
}
public static string ToJson(CustomScriptAssemblyData data)
{
return UnityEngine.JsonUtility.ToJson(data, true);
}
static void UpdateRenamedReferences(CustomScriptAssemblyData data)
{View on GitHub (pinned to 225b0fbdb5)
Solutions
- Open the .asmdef referenced in the error and add a non-empty "name" field.
- Validate .asmdef JSON before import (the editor will surface the file path).
Example fix
// before
{ "references": [] }
// after
{ "name": "MyCompany.MyFeature", "references": [] } Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(data.name))
throw new FormatException("Assembly definition is missing the required 'name' field."); Type guard
static bool HasName(CustomScriptAssemblyData d) =>
!string.IsNullOrEmpty(d?.name); Try / catch
try { asm.ValidateFields(); }
catch (Exception ex) when (ex.Message.Contains("'name'"))
{ /* open the .asmdef and add a non-empty name */ } Prevention
- Always set a unique, non-empty "name" in every .asmdef.
- Validate generated/templated .asmdef JSON before importing.
When it happens
Trigger: Loading a .asmdef whose 'name' field is null or empty, then calling ValidateFields().
Common situations: A hand-edited or generated .asmdef missing the name field, a malformed JSON, or a renamed asmdef that lost its name.
Related errors
- {reference} is not a GUID reference
- Both 'excludePlatforms' and 'includePlatforms' are set.
- Invalid Define Constraint: "{DefineConstraints[i]}" at line
- Platform name '{0}' not supported. Supported platform names:
- Assembly has duplicate references: {duplicateRefsString}
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/777555388f14290b.
Report an issue: GitHub.