{"record":{"id":"62820fa491f7d22c","repo":"Unity-Technologies/UnityCsReference","slug":"the-locationpathname-parameter-for-buildpipeline","errorCode":null,"errorMessage":"The 'locationPathName' parameter for BuildPipeline.BuildPlayer should not be null or empty.","messagePattern":"The 'locationPathName' parameter for BuildPipeline\\.BuildPlayer should not be null or empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs","lineNumber":209,"sourceCode":"        ///\n        ///It also means that the built-in scripting symbols defined for the current active target platform (such as UNITY_STANDALONE_WIN, or UNITY_ANDROID) remain in place even if you try to build for a different target platform, which can result in the wrong code being compiled into your build.</remarks>\n        ///<param name=\"buildPlayerOptions\">Provide various options to control the behavior of <see cref=\"BuildPipeline.BuildPlayer\" />.</param>\n        ///<returns>A <see cref=\"BuildReport\" /> object containing build process information.</returns>\n        ///<example>\n        ///  <code source=\"../../../Modules/ContentBuild/Tests/local.test.build-examples/Editor/BuildPipeline/BuildPipeline_BuildPlayer.cs\"/>\n        ///</example>\n        ///<seealso cref=\"BuildPlayerWindow.DefaultBuildMethods.BuildPlayer\" />\n        public static BuildReport BuildPlayer(BuildPlayerOptions buildPlayerOptions)\n        {\n            if (isBuildingPlayer)\n                throw new InvalidOperationException(\"Cannot start a new build because there is already a build in progress.\");\n\n            if (buildPlayerOptions.targetGroup == BuildTargetGroup.Unknown)\n                buildPlayerOptions.targetGroup = GetBuildTargetGroup(buildPlayerOptions.target);\n\n            string locationPathNameError;\n            if (!ValidateLocationPathNameForBuildTarget(buildPlayerOptions.locationPathName, buildPlayerOptions.target, buildPlayerOptions.subtarget, buildPlayerOptions.options, out locationPathNameError))\n                throw new ArgumentException(locationPathNameError);\n\n            string scenesError;\n            if (!ValidateScenePaths(buildPlayerOptions.scenes, out scenesError))\n                throw new ArgumentException(scenesError);\n\n            if ((buildPlayerOptions.options & BuildOptions.AcceptExternalModificationsToPlayer) == BuildOptions.AcceptExternalModificationsToPlayer)\n            {\n                CanAppendBuild canAppend = BuildCanBeAppended(buildPlayerOptions.target, buildPlayerOptions.locationPathName);\n                if (canAppend == CanAppendBuild.Unsupported)\n                    throw new InvalidOperationException(\"The build target does not support build appending.\");\n                if (canAppend == CanAppendBuild.No)\n                    throw new InvalidOperationException(\"The build cannot be appended.\");\n            }\n\n            if (buildPlayerOptions.scenes != null)\n            {\n                for (int i = 0; i < buildPlayerOptions.scenes.Length; i++)\n                    buildPlayerOptions.scenes[i] = buildPlayerOptions.scenes[i].Replace('\\\\', '/').Replace(\"//\", \"/\");","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs#L191-L227","documentation":"ArgumentException thrown by BuildPipeline.BuildPlayer when ValidateLocationPathNameForBuildTarget rejects the locationPathName because it is null or empty. The output path is required so the build system knows where to write the player binary; an empty path makes the build destination ambiguous.","triggerScenarios":"Calling BuildPipeline.BuildPlayer with buildPlayerOptions.locationPathName set to null, empty string, or whitespace. Occurs when scripts construct BuildPlayerOptions without setting the output path, when the path is read from a config that omits it, or when path-building string operations produce an empty result.","commonSituations":"Build scripts that forget to set locationPathName, CI config files with missing or commented-out output path fields, dynamic path construction where variables resolve to empty strings, platform-specific path logic that returns empty for an unsupported subtarget.","solutions":["Set buildPlayerOptions.locationPathName to a valid output path before calling BuildPlayer.","Validate the path is non-empty: if (string.IsNullOrEmpty(options.locationPathName)) { /* handle */ }","If reading the path from configuration, verify the config field exists and is non-empty.","Use platform-appropriate path construction (e.g. Path.Combine) to avoid empty segments."],"exampleFix":"// before\nvar options = new BuildPlayerOptions\n{\n    scenes = new[] { \"Assets/Scenes/Main.unity\" },\n    target = BuildTarget.StandaloneWindows64,\n    // locationPathName missing!\n};\nBuildPipeline.BuildPlayer(options);\n// after\nvar options = new BuildPlayerOptions\n{\n    scenes = new[] { \"Assets/Scenes/Main.unity\" },\n    locationPathName = \"Build/MyGame.exe\",\n    target = BuildTarget.StandaloneWindows64,\n};\nBuildPipeline.BuildPlayer(options);","handlingStrategy":"validation","validationCode":"// Validate locationPathName before calling BuildPlayer\nif (string.IsNullOrEmpty(buildPlayerOptions.locationPathName))\n{\n    Debug.LogError(\"locationPathName must not be null or empty.\");\n    return;\n}\nBuildPipeline.BuildPlayer(buildPlayerOptions);","typeGuard":"static bool HasValidOutputPath(BuildPlayerOptions options)\n    => !string.IsNullOrEmpty(options?.locationPathName);","tryCatchPattern":null,"preventionTips":["Always set locationPathName to a concrete output file path.","Validate path strings from config files before passing to BuildPlayer.","Use Path.Combine to construct paths and verify the result is non-empty.","Default to a sensible output path in build scripts to avoid accidental null."],"tags":["build-pipeline","build","validation","path","argument-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}