{"record":{"id":"0802bc449ea8b0ef","repo":"dotnet/maui","slug":"powershell-core-pwsh-is-not-installed-please-in","errorCode":null,"errorMessage":"PowerShell Core (pwsh) is not installed. Please install it to continue.","messagePattern":"PowerShell Core \\(pwsh\\) is not installed\\. Please install it to continue\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/cake/dotnet.cake","lineNumber":599,"sourceCode":"                RedirectStandardError = true\n            });\n            if (exitCode != 0)\n            {\n                Information(\"pwsh not found, falling back to powershell\");\n                pwshExecutable = \"powershell\";\n            }\n        }\n        else\n        {\n            var exitCode = StartProcess(\"which\", new ProcessSettings\n            {\n                Arguments = \"pwsh\",\n                RedirectStandardOutput = true,\n                RedirectStandardError = true\n            });\n            if (exitCode != 0)\n            {\n                throw new Exception(\"PowerShell Core (pwsh) is not installed. Please install it to continue.\");\n            }\n        }\n    }\n    catch (Exception ex) when (!IsRunningOnWindows())\n    {\n        Error(\"Error checking for pwsh: \" + ex.Message);\n        throw new Exception(\"PowerShell Core (pwsh) is required on non-Windows platforms. Please install it and try again.\");\n    }\n\n    // Execute the PowerShell script\n    StartProcess(pwshExecutable, new ProcessSettings\n    {\n        Arguments = \"-NonInteractive -ExecutionPolicy Bypass -File ./eng/scripts/update-cgmanifest.ps1\"\n    });\n});\n\nTask(\"publicapi\")\n    .Description(\"Clears PublicAPI.Unshipped.txt files and regenerates them with current public APIs. Processes Core, Controls, Essentials, and Graphics projects. Skips Windows files on non-Windows platforms and always skips Tizen files. Use after adding new public APIs to resolve build errors.\")","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/cake/dotnet.cake#L581-L617","documentation":"Thrown when the script cannot locate the pwsh executable. On non-Windows (or the fallback path) it runs `which pwsh`; a non-zero exit code means PowerShell Core is not installed or not on PATH, so the update-cgmanifest.ps1 script cannot be executed.","triggerScenarios":"The pwsh lookup branch executes `StartProcess(\"which\", \"pwsh\")` and exitCode != 0. This indicates no pwsh binary resolvable by the system PATH.","commonSituations":"Fresh Linux/macOS CI agent without PowerShell Core installed; a Docker container missing the powershell package; PATH not updated after installing pwsh via package manager.","solutions":["Install PowerShell Core: on Linux use the Microsoft package repository (`sudo apt-get install -y powershell`), on macOS use `brew install --cask powershell`.","Verify with `which pwsh` returning 0 before re-running the cake target.","In CI images, switch to an image that bundles pwsh or add an install step before the cake invocation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight check before the cgmanifest task\nvar pwshProbe = StartProcess(\"which\", new ProcessSettings { Arguments = \"pwsh\", RedirectStandardOutput = true, Silent = true });\nif (pwshProbe != 0) {\n    Information(\"pwsh not found — skipping cgmanifest update (install PowerShell Core to enable).\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add pwsh to the base CI image so the check never fails.","Document the pwsh requirement in the task's .Description attribute.","Provide a preflight validation step in the pipeline that fails fast with install instructions."],"tags":["pwsh","powershell","environment","non-windows","dependency"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}