Unity-Technologies/UnityCsReference · error · ArgumentException

The output path "{buildParameters.outputPath}" doesn't exist

Error message

The output path "{buildParameters.outputPath}" doesn't exist

What it means

Thrown by BuildAssetBundles when the outputPath directory does not exist on disk. Unlike BuildContentDirectory which attempts on-the-fly creation, BuildAssetBundles requires the output directory to already exist before the build starts.

Source

Thrown at Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs:763

                buildParameters.targetPlatform = EditorUserBuildSettings.activeBuildTarget;

                // Note: subtarget is associated with multiple enums, and 0 may have a specific meaning,
                // so we only auto-set it when the target is also coming from the build settings
                buildParameters.subtarget = EditorUserBuildSettings.GetActiveSubtargetFor(buildParameters.targetPlatform);
            }

            // For Standalone platforms, the Default subtarget means to use the current active one
            if (GetBuildTargetGroup(buildParameters.targetPlatform) == BuildTargetGroup.Standalone &&
                (StandaloneBuildSubtarget)buildParameters.subtarget == StandaloneBuildSubtarget.Default)
            {
                buildParameters.subtarget = EditorUserBuildSettings.GetActiveSubtargetFor(buildParameters.targetPlatform);
            }

            if (isBuildingPlayer)
                throw new InvalidOperationException("Cannot build asset bundles while a build is in progress.");

            if (!System.IO.Directory.Exists(buildParameters.outputPath))
                throw new ArgumentException("The output path \"" + buildParameters.outputPath + "\" doesn't exist");

            return BuildAssetBundlesInternal(buildParameters);
        }

        [NativeMethod(ThrowsException = true)]
        private static extern AssetBundleManifest BuildAssetBundlesInternal(BuildAssetBundlesParameters buildParameters);

        [FreeFunction("GetPlayerDataCache")]
        internal static extern string GetDataCacheForBuildTarget(BuildTarget target, int subtarget);

        [FreeFunction("GetPlayerDataSessionId")]
        internal static extern string GetSessionIdForBuildTarget(BuildTarget target, int subtarget);

        [FreeFunction("GetDataBuildDirtyInfoPath")]
        internal static extern string GetBuildDirtyInfoForBuildTarget(BuildTarget target, int subtarget);

        ///<summary>Extract the CRC checksum for the given AssetBundle.</summary>
        ///<remarks>A 32-bit checksum is generated during the AssetBundle build process and recorded in the .manifest file and exposed by this method.</remarks>

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Create the output directory with Directory.CreateDirectory(outputPath) before calling BuildAssetBundles.
  2. Verify Directory.Exists(outputPath) returns true before the call and log the resolved absolute path if it fails.
  3. In CI, add an explicit mkdir step or a pre-build script that ensures the directory tree exists.

Example fix

// before
string outputPath = "Build/Bundles";
BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);

// after
string outputPath = "Build/Bundles";
Directory.CreateDirectory(outputPath);
BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
Defensive patterns

Strategy: validation

Validate before calling

string EnsureOutputDirectory(string outputPath)
{
    if (!Directory.Exists(outputPath))
        Directory.CreateDirectory(outputPath);
    return outputPath;
}

// Before BuildAssetBundles:
EnsureOutputDirectory(outputPath);
BuildPipeline.BuildAssetBundles(outputPath, options, target);

Prevention

When it happens

Trigger: Calling BuildPipeline.BuildAssetBundles with an outputPath pointing to a directory that hasn't been created yet, or that was deleted between the check and the call.

Common situations: Build scripts that assume the output folder exists from a prior run, CI clean-room environments where build artifacts are wiped between runs, or paths derived from environment variables that resolve to non-existent directories.

Related errors


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