20

We want to start a company nuget package repository. Is there a way to add a package source through command line so we can configure our new package source through a setup or something?

We basically don't want to go

Tools - Options - Package Manager - Package Sources - Plus button - add name and source

on every developer machine in the company.

2
  • Haven't found it yet, would like it too Commented Sep 25, 2013 at 9:34
  • As an idea........if you run a nuget.exe from the powershell window in VS.......and override the (Sources (?)) (going from memory), I wonder if it remembers it? Probably not, but maybe worth a try. As in, the command-line version of nuget......... Commented Sep 25, 2013 at 11:00

2 Answers 2

33

The package sources are stored in NuGet.config under the user's profile or system wide in ProgramData:

%AppData%\NuGet\NuGet.config
%ProgramData%\NuGet\NuGetDefaults.config

You can add package sources through NuGet using a command line similar to:

nuget sources add -name FeedName -Source http://YourFeed.com

The above command will work if you run it under the user's profile.

NuGet 2.7 introduced system wide package source configuration in ProgramData. So you could add your package sources into NuGet.config under ProgramData with your installer.

Sign up to request clarification or add additional context in comments.

1 Comment

Putting that nuget sources add ... in an auto-ci script is OK, as it is just a warning to add the exact same source twice. That way, it doesn't matter which virtual CI system you are running on, the list gets updated.
3

You can use dotnet CLI to add a new source with following command:

dotnet nuget add source "https://nuget.pkg.github.com/Owner/index.json" --name "Source1" --username "[email protected]" --password "pass"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.