Visual Studio 2017 Nuget.config at solution folder not recognized

会有一股神秘感。 提交于 2019-12-22 11:37:24

问题


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.


回答1:


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:




回答2:


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.



来源:https://stackoverflow.com/questions/50685518/visual-studio-2017-nuget-config-at-solution-folder-not-recognized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!