"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
- Add an
actions/setup-dotnetstep early in the job sodotnetis installed and onPATH. - 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
- If installed via the dotnet-install script to a custom dir, export that dir onto
PATH. - Verify with
dotnet --info.
set PATH
export DOTNET_ROOT="$HOME/.dotnet"
export PATH="$DOTNET_ROOT:$PATH"
dotnet --infoHow to prevent it
- Install the SDK explicitly in CI rather than assuming it is present.
- Verify
dotnet --infoearly to fail fast on setup issues. - On self-managed runners, bake the SDK and PATH into the image.
Related guides
.NET SDK Version Not Found on the Runner in CIFix CI failures where the requested .NET SDK version is not on the runner - install the exact SDK with setup-…
A compatible .NET SDK was not found (global.json) in CIFix "A compatible installed .NET SDK was not found" in CI - global.json pins an SDK version that is not insta…
"dotnet test: No test is available" in CIFix "No test is available ... Make sure that test discoverer and executors are registered" in CI - a test pro…