huangbiubiu
huangbiubiu

Reputation: 1271

Restore NuGet package from 3rd party source

I tried to use command-line nuget to restore NuGet package, like:

nuget restore BuptAssistant.sln

But I used some packages from 3rd NuGet package source. In Visual Studio, I can use Options - NuGet Package Manager - Package sources to set another package source, in command-line, how to do it?

Error log can be seen in Travis CI

Upvotes: 3

Views: 3015

Answers (1)

SushiHangover
SushiHangover

Reputation: 74174

Create a Nuget.Config file in the same directory as your solution (.sln):

<?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>

Or:

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

Or:

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

Upvotes: 7

Related Questions