Unity-Technologies/UnityCsReference · error · Exception

{installPath} must not be an empty string

Error message

{installPath} must not be an empty string

What it means

Postprocess throws when installPath is String.Empty and the build is not flagged with BuildOptions.InstallInBuildFolder (or that option isn't supported for the target). An empty install path is only legal for targets that install into the build folder; otherwise a concrete output location is mandatory.

Source

Thrown at Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:337

                else
                    config.Set(keyValue.Key, keyValue.Value);
            }
        }

        [RequiredByNativeCode]
        static public void Postprocess(BuildTarget target, int subtarget, string installPath, string companyName, string productName,
            BuildOptions options,
            RuntimeClassRegistry usedClassRegistry, BuildReport report, string[] defineConstraints)
        {
            string stagingArea = "Temp/StagingArea";
            string stagingAreaData = "Temp/StagingArea/Data";
            string stagingAreaDataManaged = "Temp/StagingArea/Data/Managed";
            string playerPackage = BuildPipeline.GetPlaybackEngineDirectory(target, options);

            // Disallow providing an empty string as the installPath
            bool willInstallInBuildFolder = (options & BuildOptions.InstallInBuildFolder) != 0 && SupportsInstallInBuildFolder(target);
            if (installPath == String.Empty && !willInstallInBuildFolder)
                throw new Exception(installPath + " must not be an empty string");

            IBuildPostprocessor postprocessor = ModuleManager.GetBuildPostProcessor(target);
            if (postprocessor == null)
                // If postprocessor is not provided, build target is not supported
                throw new UnityException($"Build target '{target}' not supported");

            try
            {
                AddIconsArgs iconArgs;
                iconArgs.stagingArea = stagingArea;
                if (!postprocessor.AddIconsToBuild(iconArgs))
                    throw new BuildFailedException("Failed to add player icon");

                BuildPostProcessArgs args;
                args.target = target;
                args.subtarget = subtarget;
                args.stagingAreaData = stagingAreaData;
                args.stagingArea = stagingArea;

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Provide a non-empty installPath / locationPathName for the build.
  2. If you intend in-build-folder installation, set BuildOptions.InstallInBuildFolder and ensure the target supports it.
  3. Validate installPath is non-empty before invoking Postprocess.

Example fix

// before
BuildPipeline.BuildPlayer(new BuildPlayerOptions {
    scenes = scenes, target = BuildTarget.StandaloneWindows64,
    locationPathName = "" // empty -> throws
});

// after
BuildPipeline.BuildPlayer(new BuildPlayerOptions {
    scenes = scenes, target = BuildTarget.StandaloneWindows64,
    locationPathName = "Build/MyGame.exe"
});
Defensive patterns

Strategy: validation

Validate before calling

bool willInstallInBuildFolder = (options & BuildOptions.InstallInBuildFolder) != 0 && SupportsInstallInBuildFolder(target);
if (string.IsNullOrEmpty(installPath) && !willInstallInBuildFolder)
    throw new ArgumentException(nameof(installPath), "installPath must not be empty for this target.");

Type guard

static bool IsValidInstallPath(string path, BuildOptions opts, BuildTarget t) =>
    !string.IsNullOrEmpty(path) ||
    ((opts & BuildOptions.InstallInBuildFolder) != 0 && SupportsInstallInBuildFolder(t));

Prevention

When it happens

Trigger: Calling Postprocess (or triggering a build) with an empty installPath while BuildOptions.InstallInBuildFolder is unset or SupportsInstallInBuildFolder(target) is false.

Common situations: Programmatic BuildPipeline.BuildPlayer with an empty locationPathName for a target that requires one (e.g. Standalone, mobile); a build script forgot to set the output path.

Related errors


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