如何在Ubuntu上正确安装dotnet ef?

xuo3flqw  于 2022-11-22  发布在  其他
关注(0)|答案(2)|浏览(278)

我正在尝试在Ubuntu 20.4.1 LTS上安装dotenet ef
首先,我在全局范围内安装了该工具:
dotnet tool install --global dotnet-ef
因为它不工作,所以我把这个PATH引用添加到我的.bashrc文件的dotnet工具文件夹中:
export PATH="$PATH:$HOME/.dotnet/tools/"
如此处所示:Cannot find command '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 Core 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.

有趣的是,如果我尝试再次安装它,我被告知它已经安装。

Tool 'dotnet-ef' is already installed.

但如果我尝试使用dotnet tool list列出已安装的工具,则会得到一个空结果:

Tool 'dotnet-ef' is already installed.

我还检查了我的~/.dotnet/tools/文件夹,它是空的。
我错过了什么?

4dc9hkyq

4dc9hkyq1#

我在Ubuntu上也遇到了同样的问题。我手动安装了dotnet。由于某些原因,dotnet-ef在“/usr/share/dotnet”中查找dotnet。所以我不得不将dotnet-sdk安装在“/usr/share/dotnet”目录中,相应地更改PATH,并将DOTNET_ROOT设置为该目录。然后dotnet-ef也工作了。
顺便说一句:如果--global不起作用,你可以通过--tool-path“$HOME/.dotnet/tools”手动设置dotnet-ef的安装路径。

snz8szmq

snz8szmq2#

找到了解决办法。
将以下内容添加到.bashrc/.zshrc

export PATH="$PATH:$HOME/.dotnet/tools/"

相关问题