Azure Pipelines npm/dotnet Task - Tool Not Found
An Npm@1/DotNetCoreCLI@2 task (or a script calling npm/dotnet) could not find the tool. The SDK is not installed on the agent, the wrong version is on PATH, or the version-setup task was omitted or ordered after the use.
What this error means
The task fails reporting the tool could not be located, or a script prints npm: command not found / dotnet: command not found. On hosted agents this usually means a missing or mis-ordered setup task; on self-hosted, a missing install.
##[error]Unable to locate executable file: 'dotnet'.
+ npm ci
npm: command not foundCommon causes
SDK not installed or wrong version on PATH
Self-hosted agents need the tool installed. Hosted agents have many SDKs, but the version you need may require an explicit setup task to put it on PATH.
Setup task missing or ordered after use
A UseDotNet@2/NodeTool@0 task that selects the version must run before any task or script that uses the tool. Omitting it, or placing it later, leaves the tool unresolved.
How to fix it
Install/select the tool version before using it
Run the version-setup task first so the tool is on PATH for later steps.
steps:
- task: UseDotNet@2
inputs:
version: '8.x'
- task: NodeTool@0
inputs:
versionSpec: '20.x'
- script: |
dotnet --version
npm ciProvision the tool on self-hosted agents
- Install the required SDK/runtime on the self-hosted agent host.
- Confirm it is on the agent service's PATH (restart the agent after install).
- Pin the version with a setup task so runs are reproducible.
How to prevent it
- Place version-setup tasks before any task or script that uses the tool.
- Provision required SDKs on self-hosted agents and restart the service.
- Pin tool versions so runs are reproducible across image rollouts.