[英]Where is NuGet.Config file located in Visual Studio project?
I am wondering where is NuGet.Config file located in Visual Studio 2017 project?我想知道 Visual Studio 2017项目中的 NuGet.Config 文件在哪里? I tried to create my own NuGet.Config file in the root of the project, but I didn't find any new repositories (NuGet sources).
我尝试在项目的根目录中创建自己的 NuGet.Config 文件,但我没有找到任何新的存储库(NuGet 源)。 Does some one have any idea?
有人知道吗?
Here is the file I am trying to achieve for my .Net Core project:这是我试图为我的.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 reads NuGet.Config files from the solution root. Visual Studio 从解决方案根中读取 NuGet.Config 文件。 Try moving it there instead of placing it in the same folder as the project.
尝试将它移到那里,而不是将它放在与项目相同的文件夹中。
You can also place the file at %appdata%\\NuGet\\NuGet.Config
and it will be used everywhere.您还可以将文件放在
%appdata%\\NuGet\\NuGet.Config
,它将在任何地方使用。
https://docs.microsoft.com/en-us/nuget/schema/nuget-config-file https://docs.microsoft.com/en-us/nuget/schema/nuget-config-file
There are multiple nuget packages read in the following order:有多个 nuget 包按以下顺序读取:
NuGetDefaults.Config file
.NuGetDefaults.Config file
。 You will find this in %ProgramFiles(x86)%\\NuGet\\Config
.%ProgramFiles(x86)%\\NuGet\\Config
。%APPDATA%\\NuGet\\nuget.config
.%APPDATA%\\NuGet\\nuget.config
找到它。nuget.config
beginning from the root of your drive up to the directory where nuget.exe is called.nuget.config
的目录的任何名为nuget.config
文件。In addition to the accepted answer, I would like to add one info, that NuGet packages in Visual Studio 2017 are located in the project file itself.除了已接受的答案之外,我还想添加一个信息,即 Visual Studio 2017 中的 NuGet 包位于项目文件本身中。 Ie, right click on the project -> edit, to find all package reference entries.
即,右键单击项目 -> 编辑,以查找所有包引用条目。
If you use proxy, you will have to edit the Nuget.config file.如果使用代理,则必须编辑 Nuget.config 文件。
In Windows 7 and 10, this file is in the path:在 Windows 7 和 10 中,此文件位于以下路径中:
C:\\Users\\YouUser\\AppData\\Roaming\\NuGet. C:\\Users\\YouUser\\AppData\\Roaming\\NuGet。
Include the setting:包括设置:
<config>
<add key = "http_proxy" value = "http://Youproxy:8080" />
<add key = "http_proxy.user" value = "YouProxyUser" />
</config>
no matter where these files are here is a way to edit them via the dotnet CLI无论这些文件在哪里,都可以通过dotnet CLI编辑它们
verify 'file' to get current entries:验证“文件”以获取当前条目:
dotnet nuget list source
add new source:添加新来源:
dotnet nuget add source https://nuget.example.com -n SomeName
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.