【问题标题】:Cannot install dotnet-ef tool on Windows 11无法在 Windows 11 上安装 dotnet-ef 工具
【发布时间】:2022-07-06 06:37:53
【问题描述】:

我正在尝试通过 dotnet-cli 安装 dotnet-ef 工具。

我输入的命令:dotnet tool install --global dotnet-ef --version 6.0.4

它给了我以下错误:

C:\Users\orbit>dotnet tool install --global dotnet-ef --version 6.0.4
C:\Users\orbit\AppData\Local\Temp\yfvm4duz.fcf\restore.csproj : error NU1211: Project restore must have a single package reference(s).
C:\Users\orbit\AppData\Local\Temp\yfvm4duz.fcf\restore.csproj : error NU1212: Invalid project-package combination for Packaging.Targets 0.1.171. DotnetToolReference project style can only contain references of the DotnetTool type
The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

使用dotnet --info 命令的一些信息:

C:\Users\orbit> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.202
 Commit:    f8a55617d2

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.202\

Host (useful for support):
  Version: 6.0.4
  Commit:  be98e88c76

.NET SDKs installed:
  5.0.303 [C:\Program Files\dotnet\sdk]
  5.0.407 [C:\Program Files\dotnet\sdk]
  6.0.101 [C:\Program Files\dotnet\sdk]
  6.0.104 [C:\Program Files\dotnet\sdk]
  6.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

我可以访问https://api.nuget.org/v3/index.json,所以这不是我的互联网连接问题。

我试图删除C:\Program Files\dotnet\sdk-manifests,但没有任何结果。

我也试过dotnet tool install -g dotnet-ef --version 6.0.4 --ignore-failed-sources 命令。相同的异常消息。

我发现这个问题不仅与 dontet-ef 工具有关,而且与每个工具有关,因为我尝试安装 dotnetsay 工具并得到相同的确切错误消息。

【问题讨论】:

标签: c# .net-core entity-framework-core dotnet-tool


【解决方案1】:

尝试使用以下命令卸载它:

dotnet tool uninstall --global dotnet-ef

然后像这样安装(不带--version):

dotnet tool install --global dotnet-ef

并检查版本,如果您想更新到较新的版本,请尝试以下命令:

dotnet tool update --global dotnet-ef

【讨论】:

  • 执行卸载命令后,我得到了这个:A tool with the package Id 'dotnet-ef' could not be found. 没有 --version 该命令也不起作用。
【解决方案2】:

我通过删除解决了同样的问题

  • 来自C:\Users\%USERNAME%\.dotnet\tools 的可执行文件dotnet-ef.exe
  • 文件夹dotnet-ef来自C:\Users\%USERNAME%\.dotnet\tools\.store\

手动。

之后我用dotnet tool install --global dotnet-ef --version 6.0.6

【讨论】:

    猜你喜欢
    • 2023-03-03
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 2020-08-28
    • 2014-01-10
    • 2022-12-17
    • 2018-06-29
    相关资源
    最近更新 更多