简体   繁体   English

NuGet.Config 文件位于 Visual Studio 项目中的什么位置?

[英]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 包按以下顺序读取:

  1. First the NuGetDefaults.Config file .首先是NuGetDefaults.Config file You will find this in %ProgramFiles(x86)%\\NuGet\\Config .您将在%ProgramFiles(x86)%\\NuGet\\Config
  2. The computer-level file.计算机级文件。
  3. The user-level file.用户级文件。 You will find this in %APPDATA%\\NuGet\\nuget.config .您将在%APPDATA%\\NuGet\\nuget.config找到它。
  4. Any file named nuget.config beginning from the root of your drive up to the directory where nuget.exe is called.从驱动器的根目录开始到nuget.config的目录的任何名为nuget.config文件。
  5. The config file you specify in the -configfile option when calling nuget.exe调用 nuget.exe 时在 -configfile 选项中指定的配置文件

You can find more information here .您可以在此处找到更多信息。

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.

相关问题 无法识别解决方案文件夹中的Visual Studio 2017 Nuget.config - Visual Studio 2017 Nuget.config at solution folder not recognized 更改 nuget 包文件夹并在 Visual Studio 中使用另一个 NuGet.Config - Change nuget packages folder and use another NuGet.Config in Visual Studio 2015 visual studio Nuget程序包管理器不允许我保存新的程序包源,并且Nuget.Config无效的XML - 2015 visual studio Nuget package manager does not let me save new package sources and Nuget.Config is not valid XML 是否有将 nuget.exe 指向特定 NuGet.Config 文件的命令? - Is there a command to point nuget.exe to a specific NuGet.Config file? 具有自定义源Azure函数的NuGet.Config文件 - NuGet.Config file with custom source Azure Function 不为VS2015读取NuGet.Config文件? - NuGet.Config file is not read for VS2015? nuget.config和gui设置之间是否存在连接? - Is there a connection between nuget.config and gui settings? 以编程方式将 packageSource 添加到 Nuget.Config 中的 packageSources - Programmatically Add a packageSource to packageSources in Nuget.Config 无论如何,Nuget.config都完全忽略了 - Nuget.config ignored completely no matter what 如何在nuget.config中设置相对路径? - how to set relative path in nuget.config?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM