Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Configuration File for Solution VS2015 (NuGet 3.4+)

Okay this might sound a duplicated question, but regarding my searches it is not.

I have been looking for a proper way to configure a specific nuget package source (url) in my solution that automatically generate everything (.nuget folder and/or nuget configuration files) contrained to the solution path.

I don't want to use APPDATA neither MACHINE.

I want to use only the solution directory for everything, so when another user from the repository fetches the solution it get's everything properly installed (including the nuget references on package folder).

I have been reading NuGet documentation and it seems, the way this can be achieved is not straightforward, because of NuGet different versions and so on...

Can someone provide a minimalistic guide to achieve this purpose? Thank you for your help in advance!


Updated Question:

I notice that with NuGet Version 3.4+ I don't need the .nuget folder anymore!

My question/problem is configuring the package source url by solution and not by machine/appdata, this is because I am using a private package source url containing a feed of corporate libraries! thanks :)

Details:

I notice that the Package Sources URL are being stored in the NuGet.config file at %APPDATA%\NuGet\NuGet.Config.

How can I properly configure this by solution? so it easly maintained in a corporate business?

(I mean I don't need each user to configure the source on their machine)


From NuGet Documentation:

"A solution-specific NuGet.Config file located within a .nuget folder in the solution. Settings in this file apply only to solution-wide packages and is supported only in NuGet 3.3 and earlier. It is ignored for NuGet 3.4 and later."

Does that mean I can't properly configure sources for each solution separately? Thanks!

like image 667
TiagoM Avatar asked Nov 22 '16 16:11

TiagoM


1 Answers

Okay so here are the steps to configure it by solution (tested and applied to NuGet 3.4.4):

  1. Create/Open your solution.

  2. If it's first time and you never configured your private nuget package source you should go in your VS2015 into Tools > NuGet Package Manager > Package Manager Settings

enter image description here

  1. Fill the information required for a new package source as I describe in the image below.

enter image description here

  1. Then your Machine (AppData) NuGet configuration file will be updated at the following location: %APPDATA%\NuGet\NuGet.Config

enter image description here

  1. What you have to do next is copy this NuGet.Config file into your solution folder, like the image below!

enter image description here

Then you will notice that the package source will still be there, even if you deleted it from the AppData Folder! (Just make sure your restart your visual studio)


NOTE: If you keep the NuGet.Config file in your AppData the VS itself will concatenate the contents of the config file in AppData and the ones in your solution folder!

NOTE2: Now you just need to check-in into your Git Repository/TFS the file configuration file specified in solution folder and that's it!

like image 53
TiagoM Avatar answered Sep 19 '22 14:09

TiagoM