Assembly Definition file format reference
Assembly definition file format reference.
Read time 4 minutesLast updated 12 days ago
Assembly Definition and Assembly Definition Reference assets are JSON files. You can edit the asset files inside the Unity Editor using the window, but you can also modify the JSON content directly with an external tool.
Inspector
?
Assembly Definition JSON
An Assembly Definition is a JSON object with the following fields:
Key | Type | Required | Description |
|---|---|---|---|
| bool | Optional | False by default. For more information on the meaning of this option, refer to Allow 'unsafe' Code in General Options. |
| bool | Optional | True by default. For more information on the meaning of this option, refer to Auto Referenced in General Options. |
| string[] | Optional | Can be empty. For more information, refer to Define Constraints. |
| string[] | Optional | The platform name strings to exclude or an empty array. The |
| string[] | Optional | The platform name strings to include or an empty array. The |
| string | Required | For more information, refer to Name. |
| bool | Optional | False by default. For more information on the meaning of this option, refer to No Engine References in General Options. |
| bool | Optional | False by default. Set to true if |
| string[] | Optional | The file names of referenced DLL libraries including extension, but without other path elements. Can be empty. This array is ignored unless you set |
| string[] | Optional | References to other assemblies created with Assembly Definition assets. You can use either the GUID of the Assembly Definition asset file or the name of the assembly as defined by the You can use the Note that the Editor displays a Use GUIDs option in the Assembly Definition Inspector. This option is not serialized in the associated JSON file. Instead, the choice is inferred from the form of reference found in the file. For more information, refer to Referencing assemblies. |
| object[] | Optional | Contains an object for each version define. This object has three fields:
|
Example with assembly names and included platforms
The following example Assembly Defintion JSON uses assembly names for references to other Assembly Definitions and the key to specify an array of included platforms:
includePlatforms{ "name": "BeeAssembly", "references": [ "Unity.CollabProxy.Editor", "AssemblyB", "UnityEngine.UI", "UnityEngine.TestRunner", "UnityEditor.TestRunner" ], "includePlatforms": [ "Android", "LinuxStandalone64", "WebGL" ], "excludePlatforms": [], "overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", "nunit.framework.dll" ], "autoReferenced": false, "defineConstraints": [ "UNITY_2019", "UNITY_INCLUDE_TESTS" ], "versionDefines": [ { "name": "com.unity.ide.vscode", "expression": "[1.7,2.4.1]", "define": "MY_SYMBOL" }, { "name": "com.unity.test-framework", "expression": "[2.7.2-preview.8]", "define": "TESTS" } ], "noEngineReferences": false}
Example with GUIDs and excluded platforms
The following example Assembly Defintion JSON uses assembly GUIDs for references to other Assembly Definitions and the key to specify an array of excluded platforms:
excludePlatforms{ "name": "BeeAssembly", "references": [ "GUID:17b36165d09634a48bf5a0e4bb27f4bd", "GUID:b470eee7144904e59a1064b70fa1b086", "GUID:2bafac87e7f4b9b418d9448d219b01ab", "GUID:27619889b8ba8c24980f49ee34dbb44a", "GUID:0acc523941302664db1f4e527237feb3" ], "includePlatforms": [], "excludePlatforms": [ "iOS", "macOSStandalone", "tvOS" ], "allowUnsafeCode": false, "overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", "nunit.framework.dll" ], "autoReferenced": false, "defineConstraints": [ "UNITY_2019", "UNITY_INCLUDE_TESTS" ], "versionDefines": [ { "name": "com.unity.ide.vscode", "expression": "[1.7,2.4.1]", "define": "MY_SYMBOL" }, { "name": "com.unity.test-framework", "expression": "[2.7.2-preview.8]", "define": "TESTS" } ], "noEngineReferences": false}
Assembly Definition Reference JSON
An Assembly Definition Reference is a JSON object with only one required field: a string called . It specifies the assembly to reference, either by assembly name or by Assembly Definition asset GUID. You can use the function to retrieve the GUID of an asset. The GUID is also part of the metadata associated with every asset.
referenceAssetDatabase.AssetPathToGUIDThe following Assembly Definition Reference example references another asset by name:
{ "reference": "AssemblyA"}
The following Assembly Definition Reference example references another asset by asset GUID:
{ "reference": "GUID:f4de40948f4904ecb94b59dd38aab8a1"}