问题
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