Visual Studio项目中的NuGet.Config文件在哪里?

问题描述 投票:60回答:4

我想知道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>
c# visual-studio .net-core visual-studio-2017 visual-studio-2019
4个回答
80
投票

Visual Studio从解决方案根目录读取NuGet.Config文件。尝试将其移到那里,而不是将其放置在与项目相同的文件夹中。

您也可以将文件放置在%appdata%\NuGet\NuGet.Config,它将在任何地方使用。

https://docs.microsoft.com/en-us/nuget/schema/nuget-config-file


17
投票

有多个按以下顺序读取的nuget程序包:

  1. 首先是NuGetDefaults.Config file。您可以在%ProgramFiles(x86)%\NuGet\Config中找到它。
  2. 计算机级文件。
  3. 用户级文件。您可以在%APPDATA%\NuGet\nuget.config中找到它。
  4. 从驱动器的根目录开始,到调用nuget.exe的目录,所有名为nuget.config的文件。
  5. 您在调用nuget.exe时在-configfile选项中指定的配置文件

您可以找到更多信息here


3
投票

除了接受的答案,我还要添加一个信息,即Visual Studio 2017中的NuGet包位于项目文件本身中。即,右键单击项目->编辑,以找到所有软件包参考条目。


0
投票

如果使用代理,则必须编辑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>
© www.soinside.com 2019 - 2024. All rights reserved.