【问题标题】:"dotnet restore" fails with "Unable to locate Dependency NETStandard.Library" message“dotnet restore”失败并显示“无法找到依赖关系 NETStandard.Library”消息
【发布时间】:2015-12-18 08:50:10
【问题描述】:

我在 Mac OS X 上安装了最新的 .NET Core,并按照教程进行操作

https://dotnet.github.io/getting-started/

首先,我使用“dotnet new”创建了一个示例项目,然后运行了“dotnet restore”命令。它失败并显示以下消息:

Microsoft .NET Development Utility CoreClr-x64-1.0.0-rc1-16231

  CACHE https://api.nuget.org/v3/index.json
Restoring packages for /Users/cookie/Documents/Github/t/project.json
  GET https://api.nuget.org/v3-flatcontainer/netstandard.library/index.json
  NotFound https://api.nuget.org/v3-flatcontainer/netstandard.library/index.json 2388ms
Unable to locate Dependency NETStandard.Library >= 1.0.0-rc2-23616
Writing lock file /Users/cookie/Documents/Github/t/project.lock.json
Restore complete, 2759ms elapsed

Errors in /Users/cookie/Documents/Github/t/project.json
    Unable to locate Dependency NETStandard.Library >= 1.0.0-rc2-23616

Feeds used:
    https://api.nuget.org/v3-flatcontainer/

我收到 404 错误

https://api.nuget.org/v3-flatcontainer/netstandard.library/index.json

我在 Windows 上尝试了相同的方法,但也失败了。任何帮助将不胜感激!

编辑:这似乎是一个错误,已在 https://github.com/dotnet/cli/issues/535 中讨论过。最新安装包现在生成 NuGet.config,并成功从 myget 检索 NETStandard.Library。

【问题讨论】:

    标签: .net coreclr


    【解决方案1】:

    NETStandard.Library 尚未在 NuGet 上发布。添加

    <add key="DotNet-Core" value="https://myget.org/f/dotnet-core/api/v3/index.json" />
    

    到您的NuGet.config 文件。

    【讨论】:

    • 感谢您的回复。不幸的是我找不到 nuget.config 文件,所以我认为最新的 .NET Core 包有问题。 (我发现“dotnet new”只生成 Program.cs / .json。)所以我再次尝试下载和安装 .NET Core 安装程序,这次“dotnet new”成功生成了 NuGet.config。 (它在“dotnet-core”键中有指向myget的链接)。
    【解决方案2】:

    如果您的 nuget.config 文件看起来像我的,请在 Victor 的答案中添加一些更明确的信息。该文件有多个部分,需要将密钥添加到 &lt;configuration&gt; 内的 &lt;packageSources&gt;,以便您的文件最终看起来像这样:

        <?xml version="1.0" encoding="utf-8"?>
        <configuration>
           <packageSources>
             <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
             <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
             <add key="DotNet-Core" value="https://myget.org/f/dotnet-core/api/v3/index.json" />
          </packageSources>
         ...
    

    【讨论】:

    • 感谢您提供详细信息!正如我在 Victor 的回答中所写,我认为 .NET Core 安装程序包中存在问题。 “dotnet new”只生成了两个文件(Program.cs/json)并且没有生成 NuGet.config。我再次下载并安装了软件包,这次它会按照您的描述创建 nuget.config。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-24
    • 1970-01-01
    • 2021-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多