we are playing with Nuget and want to setup a private package source (on an internal webserver). I've followed the following instructions to add it to visual studio - (See package sources) https://docs.nuget.org/consume/Package-Manager-Dialog
I'm wondering if there's a way of scripting this outside Visual studio. (I could automatically add it to VS when I rebuild a new workstation)
NuGet package sources are stored in a NuGet.Config file that can be stored in three different places:
For the user profile the package sources are stored in the file:
%AppData%\NuGet\NuGet.Config
When you add the package source in Visual Studio this is where the package source will be saved.
For each solution Visual Studio will look in several directories for the NuGet.Config file before using the one from the user's profile. With a solution in the directory c:\Projects\MySolution then NuGet will look for this file in the directories:
Machine wide package sources are shown in the Machine-wide section of the dialog in Visual Studio. Visual Studio will look in following directories:
Note that IDE will be replaced with VisualStudio. The Version will be replaced by the Visual Studio version number. The SKU will be replaced with Ultimate, Pro, Professional or Premium.
To programatically add package sources to an NuGet.Config file you could use NuGet.exe which allows you to add or update package sources using a command line similar to:
nuget.exe sources add|update -Name [name] -Source [source]
Or you can use another tool to update the XML in the NuGet.Config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With