【问题标题】:dotnet restore fails for private nuget packages私有 nuget 包的 dotnet restore 失败
【发布时间】:2018-05-03 12:49:01
【问题描述】:

我在 windows 中开发了一个 web api (.net core) 并将其托管在 ubuntu 服务器中。我的应用程序需要来自私有 nuget 存储库的包。 我已将包源设置为nuget config -Set RepoName=http://sample-nuget-repo.net/api/odata。 我已经用 nuget 资源进行了验证。 当我运行 dotnet restore 时,它​​给了我失败消息。 如果我遗漏了什么,请帮助我。

nuget.config 文件在 ubuntu 中的位置是什么(在 windows 中是 appdata/nuget/nuget.config)

【问题讨论】:

标签: .net-core nuget ubuntu-16.04


【解决方案1】:

您可以在包含源代码的源代码控制存储库根目录中的 NuGet.Config 文件中定义自定义包源。那么你就不需要在每台机器上都配置它了。

NuGet.Config:

<configuration>
    <packageSources>
        <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
        <add key="sample-nuget-repo" value="http://sample-nuget-repo.net/api/odata" />
    </packageSources>
</configuration>

当您运行 nuget restore solution.slndotnet restore solution.sln 时,将首先检查解决方案的目录是否有 NuGet.Config 文件,然后是上面的目录,一直到根目录。最后会检查用户配置文件下的 NuGet.Config。

【讨论】:

  • 谢谢马特。是的,nuget 包源存储在 windows 的 nuget.config 中。 nuget.config 是否也是在 linux 上创建的。如果是,这个文件的位置是什么
  • 您可以在任何平台(Linux、Mac 和 Windows)上使用 NuGet.Config 文件。您只需要使用源代码创建它,因此它是独立的,不需要在构建服务器上进行额外设置)。如果您想在构建服务器上单独配置它,您需要在 ~/.config/NuGet/NuGet.config 文件中添加此信息,或使用nuget 本身在构建脚本中添加此包源。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-04
  • 2021-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多