2

I have already read similar questions but the provided answers do not resolve my issue.

I need to put all the required NuGet packages by a project inside its own folder instead of installing it to the common user directory. I need to do this so that I can put the NuGet packages under version control to make them available on other systems because some PCs cannot get the required NuGet packages from the internet.

I have already tried to put a nuget.config file inside the solution directory (as shown below in the screenshot)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value=".\packages" />
  </config>
</configuration>

enter image description here

...but even after doing that, when I install a new NuGet Package, the files are extracted to the common directory (i.e. C:\Users\TestUser\.nuget\packages\knockoutjs\3.5.1).

QUESTION: How can I set the extraction/installation of NuGet Packages to the project directory? enter image description here

skm
  • 5,015
  • 8
  • 43
  • 104
  • You can use a shared folder and put the packages there, and then make them available by adding folder's path to your %appdata%\Nuget\Nuget.config file or by adding a Nuget.config file to the solution. – McNets Apr 26 '22 at 17:54
  • @McNets: Unfortunately, a folder cannot be shared. I need to put the packages in the Git version control. – skm Apr 26 '22 at 17:58
  • Then try to copy them from their original location: `%userprofile%\.nuget\packages` and add a nuget.config file to the solution too. – McNets Apr 26 '22 at 18:00
  • @McNets Already doing that but it needs a lot of manual copying. Everytime a new NuGet package is installed, it needs to be copied to the folder manually. And, dependencies make it further complicated. – skm Apr 26 '22 at 18:09
  • Maybe [this](https://stackoverflow.com/a/47862893/3270427) helps – McNets Apr 26 '22 at 19:18

1 Answers1

0

Maybe you should move the nuget.config to the same directory as the solution and restart Visual Studio.

Peng Ge
  • 239
  • 2
  • 5