【问题标题】:dotnet tool install -g unable to resolvedotnet tool install -g 无法解决
【发布时间】:2021-09-01 00:08:11
【问题描述】:

我安装了 .NET 5 SDK,但没有安装 Visual Studio。

每当我尝试执行工具安装时,例如dotnet tool install -g csharprepl,它总是会导致:

error NU1100: Unable to resolve 'csharprepl (>= 0.0.0)' for 'net5.0'.
error NU1100: Unable to resolve 'csharprepl (>= 0.0.0)' for 'net5.0/any'.
The tool package could not be restored.
Tool 'csharprepl' 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.

在没有 Visual Studio 的情况下如何使用dotnet tool install

【问题讨论】:

    标签: .net-core nuget


    【解决方案1】:

    我在全新安装 win10/.netcore(没有 Visual Studio)时遇到了同样的问题 - 似乎默认的 NuGet.config 没有默认设置包源(至少对我而言)。

    为了解决这个问题,我在%AppData%\NuGet\ 添加了以下packageSource 配置

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <packageSources>
            <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
        </packageSources>
    </configuration>
    

    编辑:此外,您可能需要将 NuGet.exe 下载到工具文件夹,并将其添加到您的 PATH 以使用 nuget。

    【讨论】:

    • 是的,我需要先下载 NuGet.exe。谢谢。
    • 我在安装了 VS Code 的全新 dotnet 6.0 SDK 安装时遇到了同样的问题。我不必单独安装 NuGet,但 NuGet.config 文件没有包源。添加此处列出的 packageSource 配置修复了我。
    猜你喜欢
    • 2021-10-04
    • 2022-01-08
    • 2022-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-25
    • 1970-01-01
    相关资源
    最近更新 更多