Skip to content
Latchkey

"dotnet: command not found" in CI

The shell could not find the dotnet executable at all. Either no .NET SDK is installed on the runner, or it is installed but its directory is not on PATH. This is an environment-setup problem, not a project one.

What this error means

A step fails immediately with dotnet: command not found (or command not found: dotnet). Nothing about the project matters - the binary is simply not resolvable.

shell
/home/runner/work/_temp/script.sh: line 1: dotnet: command not found
Error: Process completed with exit code 127.

Common causes

No SDK installed on the runner

A minimal or container image without the .NET SDK has no dotnet binary to run.

dotnet is installed but not on PATH

A custom install location was not added to PATH, so the shell cannot find the executable.

How to fix it

Install the SDK with setup-dotnet

  1. Add an actions/setup-dotnet step early in the job so dotnet is installed and on PATH.
  2. Run build/test steps after it.
workflow setup
- uses: actions/setup-dotnet@v4
  with:
    dotnet-version: '8.0.x'

Add the install location to PATH

  1. If installed via the dotnet-install script to a custom dir, export that dir onto PATH.
  2. Verify with dotnet --info.
set PATH
export DOTNET_ROOT="$HOME/.dotnet"
export PATH="$DOTNET_ROOT:$PATH"
dotnet --info

How to prevent it

  • Install the SDK explicitly in CI rather than assuming it is present.
  • Verify dotnet --info early to fail fast on setup issues.
  • On self-managed runners, bake the SDK and PATH into the image.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →