【发布时间】: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 工具并得到相同的确切错误消息。
【问题讨论】:
-
在执行你的命令之前你能尝试安装 .net 3.1 SDK dotnet.microsoft.com/en-us/download/dotnet/3.1 吗?
-
我安装了.net 3.1 SDK,重新加载控制台,没有任何改变。
标签: c# .net-core entity-framework-core dotnet-tool