Visual Studio 2017 Nuget.config at solution folder not recognized

时间:2018-06-04 17:04:01

标签: c# visual-studio-2017 nuget nuget-package nuget-package-restore

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.

2 个答案:

答案 0 :(得分:4)

  

如何配置我的解决方案以保护其目录中的package.config文件?

要确保您的解决方案符合.nuget文件夹中的package.config文件,您应该正确配置此文件,例如,我创建了一个测试示例解决方案,然后在其中添加Nuget.config .nuget文件夹:

我的NuGet.Config文件:

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

然后,另一个重要信息是在添加Nuget.config文件后记住重新启动Visual Studio

作为测试结果,nuget包正在'D:\ Test'包文件夹中恢复:

enter image description here

答案 1 :(得分:1)

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.