dotnet/maui · error · Exception

PowerShell Core (pwsh) is not installed. Please install it…

Error message

PowerShell Core (pwsh) is not installed. Please install it to continue.

What it means

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.

Solutions

  1. Install PowerShell Core: on Linux use the Microsoft package repository (`sudo apt-get install -y powershell`), on macOS use `brew install --cask powershell`.
  2. Verify with `which pwsh` returning 0 before re-running the cake target.
  3. In CI images, switch to an image that bundles pwsh or add an install step before the cake invocation.
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight check before the cgmanifest task
var pwshProbe = StartProcess("which", new ProcessSettings { Arguments = "pwsh", RedirectStandardOutput = true, Silent = true });
if (pwshProbe != 0) {
    Information("pwsh not found — skipping cgmanifest update (install PowerShell Core to enable).");
    return;
}

Prevention

When it happens

Trigger: The pwsh lookup branch executes `StartProcess("which", "pwsh")` and exitCode != 0. This indicates no pwsh binary resolvable by the system PATH.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/0802bc449ea8b0ef. Report an issue: GitHub.

Appendix: source

Thrown at eng/cake/dotnet.cake:599

                RedirectStandardError = true
            });
            if (exitCode != 0)
            {
                Information("pwsh not found, falling back to powershell");
                pwshExecutable = "powershell";
            }
        }
        else
        {
            var exitCode = StartProcess("which", new ProcessSettings
            {
                Arguments = "pwsh",
                RedirectStandardOutput = true,
                RedirectStandardError = true
            });
            if (exitCode != 0)
            {
                throw new Exception("PowerShell Core (pwsh) is not installed. Please install it to continue.");
            }
        }
    }
    catch (Exception ex) when (!IsRunningOnWindows())
    {
        Error("Error checking for pwsh: " + ex.Message);
        throw new Exception("PowerShell Core (pwsh) is required on non-Windows platforms. Please install it and try again.");
    }

    // Execute the PowerShell script
    StartProcess(pwshExecutable, new ProcessSettings
    {
        Arguments = "-NonInteractive -ExecutionPolicy Bypass -File ./eng/scripts/update-cgmanifest.ps1"
    });
});

Task("publicapi")
    .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.")

View on GitHub (pinned to f377ff1c5e)