![](/img/trans.png)
[英]Visual Studio 2017 Nuget.config at solution folder not recognized
[英]Where is NuGet.Config file located in Visual Studio project?
我想知道 Visual Studio 2017项目中的 NuGet.Config 文件在哪里? 我尝试在项目的根目录中创建自己的 NuGet.Config 文件,但我没有找到任何新的存储库(NuGet 源)。 有人知道吗?
这是我试图为我的.Net Core项目实现的文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
<add key="AspNetCoreTools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Visual Studio 从解决方案根中读取 NuGet.Config 文件。 尝试将它移到那里,而不是将它放在与项目相同的文件夹中。
您还可以将文件放在%appdata%\\NuGet\\NuGet.Config
,它将在任何地方使用。
https://docs.microsoft.com/en-us/nuget/schema/nuget-config-file
有多个 nuget 包按以下顺序读取:
NuGetDefaults.Config file
。 您将在%ProgramFiles(x86)%\\NuGet\\Config
。%APPDATA%\\NuGet\\nuget.config
找到它。nuget.config
的目录的任何名为nuget.config
文件。您可以在此处找到更多信息。
除了已接受的答案之外,我还想添加一个信息,即 Visual Studio 2017 中的 NuGet 包位于项目文件本身中。 即,右键单击项目 -> 编辑,以查找所有包引用条目。
如果使用代理,则必须编辑 Nuget.config 文件。
在 Windows 7 和 10 中,此文件位于以下路径中:
C:\\Users\\YouUser\\AppData\\Roaming\\NuGet。
包括设置:
<config>
<add key = "http_proxy" value = "http://Youproxy:8080" />
<add key = "http_proxy.user" value = "YouProxyUser" />
</config>
无论这些文件在哪里,都可以通过dotnet CLI编辑它们
验证“文件”以获取当前条目:
dotnet nuget list source
添加新来源:
dotnet nuget add source https://nuget.example.com -n SomeName
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.