Dotnet ef – the specified command or file was not found

we might come across issues when trying to access .NET tool (dotnet ef) when it is already installed in the workstation or when trying to install or update the tool which can be a global or local tool.

There are a couple of reasons a .NET tool fails to run, most likely

  • The executable file for the tool wasn’t found.
  • The correct version of .NET runtime wasn’t found
When Executable file not found

If the executable file isn’t found then we will see the following message

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-xyz does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Global tools

Generally Global tools will install on default directory or in a specific location.

OSPath
Linux/macOS$HOME/ .dotnet/tools
Windows%USERPROFILE%\.dotnet\tools

If we are trying to use global tool, check the PATH environment variable on the work station contains the path of where the tool is installed. The .NET cli adds the default location to the PATH environment variable on its first usage. However there are some scenarios where it may not add the location in PATH. So check the PATH environment variable if tool location is not added then just add it and try.

Local tools

If we are trying to run a local version of the tool then verify there is a manifest file called dotnet-tools.json in the current directory or any of its parent directories. It may also live under .config folder anywhere in the project folder hierarchy. If manifest file exist then check the tool details, if file doesn’t contain an entry for “isRoot: true, then also check further up the file hierarchy for additional tool manifest files.

If we are trying to run a .NET tool that was installed in a specific path, then need to include that path.

..\<toolDirectory>\dotnet-<toolName>
When Runtime not found

.NET tools are framework dependent applications, which means they rely on a .NET runtime installed on the work station. If an application can’t find the required runtime, it fails to run and reports an error. We can find the installed runtime using below commands

dotnet --list-runtimes
dotnet --info

For more details follow the documentation at https://learn.microsoft.com/en-us/dotnet/core/tools/troubleshoot-usage-issues

/Siva

Leave a Reply

Scroll to Top