找不到命令 'dotnet ef' (Powershell Core - LInux)
Cannot find command 'dotnet ef' (Powershell Core - LInux)
我知道在使用传统的 Linux shell 时,关于 Dotnet-EF 有很多答案,但是当使用PowerShell Core 调用 .NET 全局工具,搜索引擎只是 运行 我在圈子里。搜索如何使用 PowerShell 处理全局工具总是 returns 篇讨论将 PowerShell 本身安装为全局工具的文章,这不是最终目标。
我确实通过 $Profile 搜索修改路径变量,但是当输入以下内容时:
$env:PATH=$HOME/.dotnet/tools
我最终会完全破坏 PowerShell,即不能 运行 任何东西; Linux CLI 程序或 PowerShell 命令。所以,我最终不得不使用 GUI 文本编辑器来删除环境变量并重新开始。即使使用单独的 envVar.ps1 也会破坏我的终端。
第一个错误:
PS /home/test> 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.
第二个错误:
PS /home/> $env:PATH='$HOME/.dotnet/tools'
PS /home/> nvim
nvim: The term 'nvim' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS /home>
(Neovim 在出错之前和变量被删除之后安装并运行良好。)
追加 - Dotnet-ef 已安装:
PS /home> get-childitem .dotnet/tools
Directory: /home/.dotnet/tools
UnixMode User Group LastWriteTime Size Name
-------- ---- ----- ------------- ---- ----
-rwxr-xr-x user user 3/29/2022 20:08 142840 dotnet-ef
PS /home/test> dotnet tool list -g
Package Id Version Commands
--------------------------------------
dotnet-ef 6.0.3 dotnet-ef
答案:
PS /home/> $env:PATH = $env:PATH + ‘:’ + ‘$HOME/.dotnet/tools'
您可能需要根据 https://docs.microsoft.com/en-us/ef/core/get-started/overview/install#get-the-net-core-cli-tools 安装 ef
工具 - 尝试 dotnet tool list
,如果您在输出中看不到它,那么 运行 这个:
dotnet tool install --global dotnet-ef
关于 PATH
环境变量,您 覆盖 值而不是附加额外的文件夹名称,这就是操作系统找不到的原因之后的其他应用程序。
你可能想要这样的东西
PS /home/> $env:PATH = $env:PATH + ‘;’ + ‘$HOME/.dotnet/tools'
我知道在使用传统的 Linux shell 时,关于 Dotnet-EF 有很多答案,但是当使用PowerShell Core 调用 .NET 全局工具,搜索引擎只是 运行 我在圈子里。搜索如何使用 PowerShell 处理全局工具总是 returns 篇讨论将 PowerShell 本身安装为全局工具的文章,这不是最终目标。
我确实通过 $Profile 搜索修改路径变量,但是当输入以下内容时:
$env:PATH=$HOME/.dotnet/tools
我最终会完全破坏 PowerShell,即不能 运行 任何东西; Linux CLI 程序或 PowerShell 命令。所以,我最终不得不使用 GUI 文本编辑器来删除环境变量并重新开始。即使使用单独的 envVar.ps1 也会破坏我的终端。
第一个错误:
PS /home/test> 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.
第二个错误:
PS /home/> $env:PATH='$HOME/.dotnet/tools'
PS /home/> nvim
nvim: The term 'nvim' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS /home>
(Neovim 在出错之前和变量被删除之后安装并运行良好。)
追加 - Dotnet-ef 已安装:
PS /home> get-childitem .dotnet/tools
Directory: /home/.dotnet/tools
UnixMode User Group LastWriteTime Size Name
-------- ---- ----- ------------- ---- ----
-rwxr-xr-x user user 3/29/2022 20:08 142840 dotnet-ef
PS /home/test> dotnet tool list -g
Package Id Version Commands
--------------------------------------
dotnet-ef 6.0.3 dotnet-ef
答案:
PS /home/> $env:PATH = $env:PATH + ‘:’ + ‘$HOME/.dotnet/tools'
您可能需要根据 https://docs.microsoft.com/en-us/ef/core/get-started/overview/install#get-the-net-core-cli-tools 安装 ef
工具 - 尝试 dotnet tool list
,如果您在输出中看不到它,那么 运行 这个:
dotnet tool install --global dotnet-ef
关于 PATH
环境变量,您 覆盖 值而不是附加额外的文件夹名称,这就是操作系统找不到的原因之后的其他应用程序。
你可能想要这样的东西
PS /home/> $env:PATH = $env:PATH + ‘;’ + ‘$HOME/.dotnet/tools'