Unity-Technologies/UnityCsReference · error · ArgumentException

Build profile name is too long ({byteCount}) - max supported

Error message

Build profile name is too long ({byteCount}) - max supported is {BuildProfileModuleUtil.k_MaxAssetFileNameLength} bytes.

What it means

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.

Source

Thrown at Editor/Mono/BuildProfile/BuildProfile.Create.cs:212

                if (guid == platformGuid)
                    return;
            }

            throw new ArgumentException(
                $"Platform GUID {platformGuid} is not a valid Unity build platform.");
        }

        /// <summary>
        /// Validates if the provided path name length is supported by the Asset database.
        /// Throws an ArgumentException if the platform is not valid.
        /// </summary>
        /// <param name="assetPath">The path to the build profile to be created.</param>
        static void ValidateFileNameLength(string assetPath)
        {
            var byteCount = System.Text.Encoding.UTF8.GetByteCount(Path.GetFileName(assetPath));
            // File name length is limited by the asset database
            if (byteCount > BuildProfileModuleUtil.k_MaxAssetFileNameLength)
                throw new ArgumentException($"Build profile name is too long ({byteCount}) - max supported is {BuildProfileModuleUtil.k_MaxAssetFileNameLength} bytes.");
        }

        internal void NotifyBuildProfileExtensionOfCreation(int preconfiguredSettingsVariant)
        {
            var buildProfileExtension = BuildProfileModuleUtil.GetBuildProfileExtension(platformGuid);
            if (buildProfileExtension != null)
            {
                buildProfileExtension.OnBuildProfileCreated(this, preconfiguredSettingsVariant);
                AssetDatabase.SaveAssetIfDirty(this);
            }
        }

        void TryCreatePlatformSettings()
        {
            if (platformBuildProfile != null)
            {
                Debug.LogError("[BuildProfile] Platform settings already created.");
                return;

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Shorten the profile name so the file name's UTF-8 byte length stays under k_MaxAssetFileNameLength.
  2. Avoid heavy multi-byte characters in the profile name when length is a concern.
  3. Compute the byte length up front (Encoding.UTF8.GetByteCount) before calling create and trim if necessary.

Example fix

// before
BuildProfile.Create(guid, "ThisIsAVeryLongProfileNameThatExceedsTheAssetDatabaseByteLimit");

// after
var name = "ShortName";
// optional guard:
if (System.Text.Encoding.UTF8.GetByteCount(name) > BuildProfileModuleUtil.k_MaxAssetFileNameLength)
    name = name.Substring(0, 32);
Defensive patterns

Strategy: validation

Validate before calling

int bytes = System.Text.Encoding.UTF8.GetByteCount(System.IO.Path.GetFileName(name));
if (bytes <= BuildProfileModuleUtil.k_MaxAssetFileNameLength) /* ok */;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/64259116de690dcb. Report an issue: GitHub.