【问题标题】:Installed Dotnet tools give error "Could not execute because the specified command or file was not found." on Ubuntu WSL2安装的 Dotnet 工具给出错误“无法执行,因为找不到指定的命令或文件。”在 Ubuntu WSL2 上
【发布时间】:2021-06-24 01:34:30
【问题描述】:

我正在 wsl2 中的 .net core 5 中开发一个 api,我按照所有文档安装实体框架核心工具。

当我跑步时

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 上或更改我的路径,如果没有发生什么。

【问题讨论】:

    标签: c# entity-framework .net-core command-line-interface wsl-2


    【解决方案1】:

    我发现了这篇文章: Cannot find command 'dotnet ef'

    正在运行

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

    让 dotnet ef 工作,直到我开始一个新的终端会话,所以我想仔细检查正确的方法来使它成为永久修复,根据这篇文章,我发现 https://astrobiomike.github.io/unix/modifying_your_path 处理它的最佳方法就是添加它到您的 bash_profile 或 zshrc,这就是我所做的

    【讨论】:

    • 如果.dotnet/下没有tools目录?
    猜你喜欢
    • 2020-05-18
    • 1970-01-01
    • 1970-01-01
    • 2020-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    • 2022-08-11
    相关资源
    最近更新 更多