从第 3 方源恢复 NuGet 包

Restore NuGet package from 3rd party source

我尝试使用命令行 nuget 来恢复 NuGet 包,例如:

nuget restore BuptAssistant.sln

但我使用了 3rd NuGet 包源中的一些包。在 Visual Studio 中,我可以使用 Options - NuGet Package Manager - Package sources 设置另一个包源,在命令行中,如何做?

错误日志可见Travis CI

在与您的解决方案 (.sln) 相同的目录中创建一个 Nuget.Config 文件:

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

或者:

nuget sources Add -Name "MyCustomSource" -source https://yournnugetserver.com/api/v3/
nuget restore MySolution.sln

或者:

nuget restore MySolution.sln -source "https://www.nuget.org/api/v3;https://yournnugetserver.com/api/v3/"