{"record":{"id":"5e61c2a6e8202c01","repo":"Unity-Technologies/UnityCsReference","slug":"build-location-for-buildtarget-buildtarget-is-no","errorCode":null,"errorMessage":"Build location for buildTarget {buildTarget} is not valid.","messagePattern":"Build location for buildTarget (.+?) is not valid\\.","errorType":"exception","errorClass":"BuildMethodException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPlayerWindowBuildMethods.cs","lineNumber":315,"sourceCode":"                        {\n                            EditorUtility.DisplayDialog(\"Invalid build path\", msg, \"OK\");\n                            Debug.LogError($\"Invalid build path: '{buildPath}'. {msg}\");\n                            throw new BuildMethodException();\n                        }\n\n                        if (BuildPipeline.BuildCanBeAppended(buildTarget, buildPath) == CanAppendBuild.Yes)\n                            updateExistingBuild = true;\n                    }\n                    else\n                    {\n                        if (askForBuildLocation && !PickBuildLocation(buildTargetGroup, buildTarget, subtarget, options.options, out updateExistingBuild))\n                            throw new BuildMethodException();\n\n                        var newLocation = EditorUserBuildSettings.GetBuildLocation(buildTarget);\n\n                        if (newLocation.Length == 0)\n                        {\n                            throw new BuildMethodException(\"Build location for buildTarget \" + buildTarget + \" is not valid.\");\n                        }\n\n                        if (!askForBuildLocation)\n                        {\n                            switch (BuildPipeline.BuildCanBeAppended(buildTarget, newLocation))\n                            {\n                                case CanAppendBuild.Unsupported:\n                                    break;\n                                case CanAppendBuild.Yes:\n                                    updateExistingBuild = true;\n                                    break;\n                                case CanAppendBuild.No:\n                                    if (!PickBuildLocation(buildTargetGroup, buildTarget, subtarget, options.options, out updateExistingBuild))\n                                        throw new BuildMethodException();\n\n                                    newLocation = EditorUserBuildSettings.GetBuildLocation(buildTarget);\n                                    if (!BuildLocationIsValid(newLocation))\n                                        throw new BuildMethodException(\"Build location for buildTarget \" + buildTarget + \" is not valid.\");","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPlayerWindowBuildMethods.cs#L297-L333","documentation":"During build-location resolution, if the user did not pick a location and EditorUserBuildSettings.GetBuildLocation(buildTarget) returns an empty string, the build aborts with BuildMethodException. An empty stored location means no valid output path is available for the target.","triggerScenarios":"askForBuildLocation is false (or the picker was bypassed) and GetBuildLocation(buildTarget) returns \"\"; no prior build location was ever recorded for the target.","commonSituations":"Headless/CI build that skips the location picker without pre-setting a build location; first build for a target where no location has been chosen before; a build script cleared the stored location.","solutions":["Pre-set the build location via EditorUserBuildSettings.SetBuildLocation(buildTarget, path) before building.","Allow the location picker (askForBuildLocation) so the user can choose a path.","Pass an explicit locationPathName in BuildPlayerOptions instead of relying on stored settings."],"exampleFix":"// before\nEditorUserBuildSettings.SetBuildLocation(BuildTarget.StandaloneWindows64, \"\");\n// ... build with askForBuildLocation=false -> throws\n\n// after\nEditorUserBuildSettings.SetBuildLocation(BuildTarget.StandaloneWindows64, \"/abs/path/Build\");\n// then build","handlingStrategy":"validation","validationCode":"var loc = EditorUserBuildSettings.GetBuildLocation(buildTarget);\nif (string.IsNullOrEmpty(loc))\n    EditorUserBuildSettings.SetBuildLocation(buildTarget, Path.GetFullPath(defaultPath));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-set the build location via SetBuildLocation for headless/CI builds.","Pass an explicit locationPathName in BuildPlayerOptions instead of relying on stored settings."],"tags":["build-player","build-location","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}