Siva
Siva

Reputation: 1411

Not able to install NuGet packages to desired location

Currently when I am installing Nuget Packages it is installing in a folder called "packages" which is exactly in solution directory. But I want this package to be installed under my project location.

Example:

SolutionFolder:
-->ProjectFolder
    -->Project1

I want the package to be installed under "ProjectFolder" location. To do this, I followed the approach suggested in Change installation location of Nuget Package

I added nuget.config file under "SolutionFolder" as below:

<configuration>
  <config>
    <add key="repositoryPath" value="C:\SolutionFolder\ProjectFolder\packages"/>
  </config>
</configuration>

My expectation is something below:

SolutionFolder:
-->ProjectFolder
    -->packages
    -->Project1

But Actual result is as below:

SolutionFolder:
-->packages
-->ProjectFolder
    -->Project1

It is still creating "packages" folder under solution root directory only.

Could some one correct me where I am doing wrong.

Upvotes: 1

Views: 634

Answers (1)

Ali Ezzat Odeh
Ali Ezzat Odeh

Reputation: 2163

Add NuGet.CONFIG file next to your solution file with following content :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
    <add key="repositoryPath" value="..\..\NuGetPackages" /><!--in value fill required directory-->
</config>
<packageRestore>
    <!-- Allow NuGet to download missing packages -->
    <add key="enabled" value="True" />
    <!-- Automatically check for missing packages during build in Visual Studio -->
    <add key="automatic" value="True" />
</packageRestore>
<solution>
    <add key="disableSourceControlIntegration" value="false" />
</solution>
</configuration>

Upvotes: 1

Related Questions