{"record":{"id":"c11c6ce6c606ecee","repo":"Unity-Technologies/UnityCsReference","slug":"for-the-0-target-the-locationpathname-parame","errorCode":null,"errorMessage":"For the '{0}' target the 'locationPathName' parameter for BuildPipeline.BuildPlayer should not end with a directory separator.\nProvided path: '{1}', expected a path with the extension '.{2}'.","messagePattern":"For the '(.+?)' target the 'locationPathName' parameter for BuildPipeline\\.BuildPlayer should not end with a directory separator\\.\nProvided path: '(.+?)', expected a path with the extension '\\.(.+?)'\\.","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 ends with a directory separator character (indicating a folder path rather than a file path) or does not have the expected file extension for the target platform. The message is a format string with the target name, provided path, and expected extension as parameters.","triggerScenarios":"Calling BuildPipeline.BuildPlayer with a locationPathName that ends in '/' or '\\\\' (e.g. \"Build/\") or that lacks the correct extension for the target (e.g. \"Build/app\" instead of \"Build/app.exe\" for Windows, \"Build/app.app\" for macOS, \"Build/app.apk\" for Android). The validation function checks the path against platform-specific expectations.","commonSituations":"Scripts that set locationPathName to a directory path instead of a file path, platform-switching build scripts that reuse a generic path without adjusting the extension, CI configs that specify output folders rather than output files, cross-platform path handling that drops the extension.","solutions":["Provide a full file path with the correct extension for the target platform (e.g. .exe for Windows, .app for macOS, .apk for Android).","Ensure the path does not end with a directory separator.","Use platform-aware path construction: append the correct extension based on BuildTarget.","Check the error message for the expected extension and adjust the path accordingly."],"exampleFix":"// before\noptions.locationPathName = \"Build/MyGame/\"; // ends with separator\n// or\noptions.locationPathName = \"Build/MyGame\"; // no extension\n// after — platform-appropriate file path with extension\noptions.locationPathName = BuildTarget == BuildTarget.StandaloneWindows64\n    ? \"Build/MyGame/MyGame.exe\"\n    : BuildTarget == BuildTarget.StandaloneOSX\n        ? \"Build/MyGame/MyGame.app\"\n        : \"Build/MyGame/MyGame.apk\";","handlingStrategy":"validation","validationCode":"// Validate locationPathName format for the target platform\nstring GetExpectedExtension(BuildTarget target)\n{\n    switch (target)\n    {\n        case BuildTarget.StandaloneWindows:\n        case BuildTarget.StandaloneWindows64:\n            return \".exe\";\n        case BuildTarget.StandaloneOSX:\n            return \".app\";\n        case BuildTarget.Android:\n            return \".apk\";\n        default:\n            return \"\";\n    }\n}\n\nstring expected = GetExpectedExtension(buildPlayerOptions.target);\nif (string.IsNullOrEmpty(expected) || !buildPlayerOptions.locationPathName.EndsWith(expected))\n{\n    Debug.LogError($\"locationPathName must end with '{expected}' for {buildPlayerOptions.target}.\");\n    return;\n}\nif (buildPlayerOptions.locationPathName.EndsWith(\"/\") || buildPlayerOptions.locationPathName.EndsWith(\"\\\\\"))\n{\n    Debug.LogError(\"locationPathName must not end with a directory separator.\");\n    return;\n}\nBuildPipeline.BuildPlayer(buildPlayerOptions);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the platform-specific file extension in locationPathName.","Never end locationPathName with a directory separator.","Build path construction logic per-platform to append the correct extension.","Cross-reference the error message for the expected extension when troubleshooting."],"tags":["build-pipeline","build","validation","path","platform","argument-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}