{"record":{"id":"64259116de690dcb","repo":"Unity-Technologies/UnityCsReference","slug":"build-profile-name-is-too-long-bytecount-max","errorCode":null,"errorMessage":"Build profile name is too long ({byteCount}) - max supported is {BuildProfileModuleUtil.k_MaxAssetFileNameLength} bytes.","messagePattern":"Build profile name is too long \\((.+?)\\) - max supported is (.+?) bytes\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildProfile/BuildProfile.Create.cs","lineNumber":212,"sourceCode":"                if (guid == platformGuid)\n                    return;\n            }\n\n            throw new ArgumentException(\n                $\"Platform GUID {platformGuid} is not a valid Unity build platform.\");\n        }\n\n        /// <summary>\n        /// Validates if the provided path name length is supported by the Asset database.\n        /// Throws an ArgumentException if the platform is not valid.\n        /// </summary>\n        /// <param name=\"assetPath\">The path to the build profile to be created.</param>\n        static void ValidateFileNameLength(string assetPath)\n        {\n            var byteCount = System.Text.Encoding.UTF8.GetByteCount(Path.GetFileName(assetPath));\n            // File name length is limited by the asset database\n            if (byteCount > BuildProfileModuleUtil.k_MaxAssetFileNameLength)\n                throw new ArgumentException($\"Build profile name is too long ({byteCount}) - max supported is {BuildProfileModuleUtil.k_MaxAssetFileNameLength} bytes.\");\n        }\n\n        internal void NotifyBuildProfileExtensionOfCreation(int preconfiguredSettingsVariant)\n        {\n            var buildProfileExtension = BuildProfileModuleUtil.GetBuildProfileExtension(platformGuid);\n            if (buildProfileExtension != null)\n            {\n                buildProfileExtension.OnBuildProfileCreated(this, preconfiguredSettingsVariant);\n                AssetDatabase.SaveAssetIfDirty(this);\n            }\n        }\n\n        void TryCreatePlatformSettings()\n        {\n            if (platformBuildProfile != null)\n            {\n                Debug.LogError(\"[BuildProfile] Platform settings already created.\");\n                return;","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildProfile/BuildProfile.Create.cs#L194-L230","documentation":"Thrown by ValidateFileNameLength(string assetPath) when the UTF-8 byte count of the profile's file name exceeds BuildProfileModuleUtil.k_MaxAssetFileNameLength. The method measures bytes (not characters) via Encoding.UTF8.GetByteCount on Path.GetFileName(assetPath), because the asset database imposes a byte-length limit on file names. Exceeding it throws ArgumentException with the measured and maximum byte counts.","triggerScenarios":"Providing a profileName that, combined with the generated asset path, produces a file name whose UTF-8 byte length exceeds the asset database limit. Multi-byte characters (CJK, emoji) count more, so fewer characters may still exceed the byte budget.","commonSituations":"Long or descriptive profile names; non-ASCII names (CJK, accented characters) where each character is 2-4 bytes; auto-generated names with timestamps or build numbers appended.","solutions":["Shorten the profile name so the file name's UTF-8 byte length stays under k_MaxAssetFileNameLength.","Avoid heavy multi-byte characters in the profile name when length is a concern.","Compute the byte length up front (Encoding.UTF8.GetByteCount) before calling create and trim if necessary."],"exampleFix":"// before\nBuildProfile.Create(guid, \"ThisIsAVeryLongProfileNameThatExceedsTheAssetDatabaseByteLimit\");\n\n// after\nvar name = \"ShortName\";\n// optional guard:\nif (System.Text.Encoding.UTF8.GetByteCount(name) > BuildProfileModuleUtil.k_MaxAssetFileNameLength)\n    name = name.Substring(0, 32);","handlingStrategy":"validation","validationCode":"int bytes = System.Text.Encoding.UTF8.GetByteCount(System.IO.Path.GetFileName(name));\nif (bytes <= BuildProfileModuleUtil.k_MaxAssetFileNameLength) /* ok */;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep profile names short.","Account for multi-byte characters when sizing names.","Compute UTF-8 byte length before creating a profile."],"tags":["unity","buildprofile","filename","length-limit","utf8","argumentexception"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}