Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 556
huangbiubiu Avatar asked Dec 08 '25 08:12

huangbiubiu


1 Answers

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/"
like image 57
SushiHangover Avatar answered Dec 10 '25 06:12

SushiHangover



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!