简体   繁体   English

zsh:找不到命令:dotnet-ef

[英]zsh: command not found: dotnet-ef

I am using asp.net core 2.1 with visual studio code or rider in mac.我在 mac 中使用带有 Visual Studio 代码或骑手的 asp.net core 2.1。 I already have a 2.1 sdk install on mac, while using the below command我已经在 mac 上安装了 2.1 sdk,同时使用以下命令

dotnet-ef database update --project XXXX.XXXX

I get an exception as我得到一个例外

zsh: command not found: dotnet-ef

Using the command使用命令

dotnet tool install --global dotnet-ef

getting an exception as Tool 'dotnet-ef' is already installed.由于Tool 'dotnet-ef' is already installed. ,因此出现异常Tool 'dotnet-ef' is already installed.

Then using this command dotnet tool restore然后使用这个命令dotnet tool restore

error NU3037: Package 'dotnet-ef 3.1.1' from source 'https://api.nuget.org/v3/index.json': The repository countersignature validity period has expired.

Package "dotnet-ef" failed to restore, due to Microsoft.DotNet.ToolPackage.ToolPackageException: The tool package could not be restored.

对于 mac 我需要导出以下路径

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

Yes, give an example of the error:是的,举个错误的例子:

$ 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.

The second and third refer to dotnet trying to find a dotnet-ef command but it cannot find it.第二个和第三个是指 dotnet 尝试查找 dotnet-ef 命令但找不到它。 As the third point said, dotnet-ef is not on your way.正如第三点所说,dotnet-ef 不在你的路上。

This is what thedocumentation says:这是文档所说的:

Global tools can be installed in the default directory or in a specific location. The default directory is:

OS Path

Linux/macOS $HOME/.dotnet/tools

Windows %USERPROFILE%\.dotnet\tools

So, you should add $HOME/.dotnet/tools/ to your $PATH.因此,您应该将 $HOME/.dotnet/tools/ 添加到您的 $PATH。

For Linux and macOS, add a line to the shell configuration:对于 Linux 和 macOS,在 shell 配置中添加一行:

bash/ zsh: bash/ zsh:

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

When you start a new shell/terminal (or next time you log in) dotnet ef should work.当你启动一个新的 shell/终端(或下次登录时) dotnet ef 应该可以工作。

For Windows:对于 Windows:

You need to add %USERPROFILE%.dotnet\\tools to PATH.您需要将 %USERPROFILE%.dotnet\\tools 添加到 PATH。

I am using asp.net core 6.0 zhengguo@macdeMac-min % echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands我正在使用 asp.net core 6.0 zhengguo@macdeMac-min % echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/公共:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

The PATH has already exist ~/.dotnet/tools When I use dotnet aspnet-codegenerator, it works. PATH 已经存在 ~/.dotnet/tools 当我使用 dotnet aspnet-codegenerator 时,它可以工作。 dotnet-aspnet-codegenerator not work. dotnet-aspnet-codegenerator 不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM