【问题标题】:zsh: command not found: dotnet-efzsh:找不到命令:dotnet-ef
【发布时间】:2021-12-21 22:59:16
【问题描述】:

我在 mac 中使用带有 Visual Studio 代码或 Rider 的 asp.net core 2.1。我已经在 mac 上安装了 2.1 sdk,同时使用以下命令

dotnet-ef database update --project XXXX.XXXX

我得到一个例外

zsh: command not found: dotnet-ef

使用命令

dotnet tool install --global dotnet-ef

Tool 'dotnet-ef' is already installed. 获得异常

然后使用这个命令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.

【问题讨论】:

    标签: c# asp.net asp.net-core .net-core dotnet-cli


    【解决方案1】:

    对于mac我需要导出下面的路径

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

    【讨论】:

      【解决方案2】:

      是的,举个错误的例子:

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

      第二个和第三个是 dotnet 试图找到一个 dotnet-ef 命令但它找不到它。正如第三点所说,dotnet-ef 不在你的路上。

      documentation 是这么说的:

      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
      

      因此,您应该将 $HOME/.dotnet/tools/ 添加到您的 $PATH。

      对于 Linux 和 macOS,在 shell 配置中添加一行:

      bash/zsh:

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

      当您启动一个新的 shell/终端(或下次登录)时,dotnet ef 应该可以工作。

      对于 Windows:

      您需要将 %USERPROFILE%.dotnet\tools 添加到 PATH。

      【讨论】:

        【解决方案3】:

        我正在使用 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

        PATH 已经存在 ~/.dotnet/tools 当我使用 dotnet aspnet-codegenerator 时,它可以工作。 dotnet-aspnet-codegenerator 不工作。

        【讨论】:

          猜你喜欢
          • 2019-11-13
          • 2019-11-25
          • 2016-07-30
          • 2015-07-01
          • 2017-08-09
          • 2016-04-12
          • 2016-06-26
          • 2021-12-15
          相关资源
          最近更新 更多