我在 mac 中使用帶有 Visual Studio 代碼或騎手的 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.
uj5u.com熱心網友回復:
對于 mac 我需要匯出以下路徑
export PATH="$PATH:$HOME/.dotnet/tools/"
uj5u.com熱心網友回復:
是的,舉個錯誤的例子:
$ 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 不在你的路上。
這是檔案所說的:
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。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/354932.html
標籤:C# asp.net asp.net核心 .net核心 dotnet-cli
上一篇:在Angular中使用Observables顯示資料時出錯
下一篇:根據條件顯示主頁
