.NET Core 全局工具安装在某些 Windows 计算机上失败并出现以下错误:
Failed to install tool package 'amazon.lambda.tools': Could not find a part of the path 'C:\Users\myUser\.dotnet\tools\.store\.stage\xxx.yyy\amazon.lambda.tools'.
Tool 'amazon.lambda.tools' 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 Core 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
上面的示例尝试安装 Amazon.Lambda.Tools;但是其他常用工具(例如 dotnetsay)给出了相同的结果。
我只在一个环境中观察到了这一点:我的开发团队用作 TFS 2017 构建代理的 Windows Server 2016 虚拟机。服务器已安装 Visual Studio 2017 和 2019,以及 Visual Studio 2017 和 2019 构建工具。服务器不在代理后面。同一 VLAN 上的其他 Windows Server 2016 虚拟机能够成功执行安装。
C:\Users\myUser>dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.101
Commit: b377529961
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.101\
Host (useful for support):
Version: 3.1.1
Commit: a1388f194c
.NET Core SDKs installed:
3.1.101 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
以下是不成功的:
--add-source
的文件参数(远射,我知道)。 --version
在安装过程中。 我已经确定了一个解决方法:将 C:\Users\myUser.dotnet\tools 从安装成功的计算机复制到安装失败的计算机上的相同位置。这样做允许使用全局工具,就像安装成功一样。当然,这不是最佳解决方案,但我提到它是为了更好地理解潜在问题。
我不知道
dotnet tool install
的内部工作原理命令,但我可以很容易地想象“找不到路径的一部分......”是一种方法的失败,该方法期望将某些下载的内容放置在临时文件夹中,但发现情况并非如此。如果这是真的,那么这可能是(如错误所暗示的)下载失败的结果......日志只是没有告诉我它下载失败的资源,而且我无法找到 .nupkg用于 Github 上的 Amazon.Lambda.Tools(尝试手动指定 URL)。这个问题有已知的解决方案吗?如果没有,那么我是否可以采取任何进一步的步骤来诊断工具安装?我确信报告的错误“找不到路径的一部分...”只是错误的副作用,我无法通过控制台看到它。
最佳答案
我在安装 Amazon.Lambda.Tools
时遇到了同样的问题但指定包版本为我解决了这个问题:
dotnet tool install --global Amazon.Lambda.Tools --version 4.1.0
运行以下命令时导致与您报告的错误相同dotnet tool install --global Amazon.Lambda.Tools
为确保您安装的是此软件包的最新版本,请检查 nuget 提要 here .
关于c# - 安装 .NET Core 全局工具时出错 : "Could not find a part of the path...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60403432/