我正在 wsl2 的 .net core 5 中开发一个 api,我按照所有文档安装了 Entity Framework 核心工具。
当我运行时
dotnet tool list -g
它打印
Package Id Version Commands
--------------------------------------
dotnet-ef 5.0.7 dotnet-ef
但是当我运行的时候
dotnet ef
或其任何子命令,我明白了
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-ef 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.
现在,我看着我的路径,看起来就像我运行时的样子
dotnet tool install --global dotnet-ef
它将它安装在我的 C 驱动器下而不是 wsl2 中,我认为这可能是问题所在,但我不明白为什么在 ubuntu 中运行它会将它安装到我的 Windows 目录中,但这是我路径中的行
/mnt/c/Users/ethan/.dotnet/tools
所以我想我的问题是,问题是它在我的 Windows 目录下没有停止吗?如果是,我如何强制它安装在 ububtu 上或更改我的路径,如果没有,发生了什么。
最佳答案
我找到这篇文章: Cannot find command 'dotnet ef'
正在运行
export PATH="$PATH:$HOME/.dotnet/tools/"
使 dotnet ef 工作,直到我开始一个新的终端 session ,所以我想仔细检查正确的方法以使其成为永久修复,根据我发现的这篇文章 https://astrobiomike.github.io/unix/modifying_your_path处理它的最佳方法就是将它添加到您的 bash_profile 或 zshrc,这就是我所做的
关于c# - 安装的 Dotnet 工具在 Ubuntu WSL2 上给出错误 "Could not execute because the specified command or file was not found.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68108640/