Evan Park
Evan Park

Reputation: 538

Visual Studio 2017 Nuget.config at solution folder not recognized

I'm having issue with visual studio 2017,

where new solution keeps referencing the Nuget.config file in unexpected location in 'C:\Users\yopa\AppData\Roaming\NuGet\Nuget.config'.

I've added '/.nuget/Nuget.config' file to my solutions folder.

However, the solution is still referencing the nuget configuration file in the 'C:\', and the nuget packages are being restored in 'C:\' package folder as well.

How do I configure my solution to honour package.config file in its directory?

I've tried deleting the nuget.config file in the roaming folder, but the solution re-creates the file when nuget package restore is done.

Upvotes: 2

Views: 10147

Answers (2)

Leo Liu
Leo Liu

Reputation: 76996

How do I configure my solution to honour package.config file in its directory?

To make sure your solution to honor the package.config file in the .nuget folder, you should configure this file correctly, for example, I created a test sample solution, then add a Nuget.config inside .nuget folder:

My NuGet.Config file:

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

Then, another important info is remember restart Visual Studio after adding the Nuget.config file.

As test result, the nuget packages are being restored in 'D:\Test' package folder:

enter image description here

Upvotes: 13

Uladz
Uladz

Reputation: 1978

Looks like solution wide Nuget.config inside .nuget folder is no longer supported.

NuGet 3.3 and earlier used a .nuget folder for solution-wide settings. This file is not used in NuGet 3.4+.

Config file should be placed at the project level or any folder in the project path instead, check documentation for additional details Configuring nuget behavior.

Upvotes: 3

Related Questions