Where is NuGet.Config file located in Visual Studio project?

153,675

Solution 1

Visual Studio reads NuGet.Config files from the solution root. 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.

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

Solution 2

There are multiple nuget packages read in the following order:

  1. First the NuGetDefaults.Config file. You will find this in %ProgramFiles(x86)%\NuGet\Config.
  2. The computer-level file.
  3. The user-level file. You will find this in %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.
  5. The config file you specify in the -configfile option when calling nuget.exe

You can find more information here.

Solution 3

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. I.e., right click on the project -> edit, to find all package reference entries.

Solution 4

If you use proxy, you will have to edit the Nuget.config file.

In Windows 7 and 10, this file is in the path:
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>
Share:
153,675

Related videos on Youtube

Mohammed Noureldin
Author by

Mohammed Noureldin

Austrian software engineer with a focus not only on coding, but also on every single detail of software engineering, equipped with a diversity of promising and useful skills, like deep knowledge in different programming languages and frameworks, hands-on embedded systems, and a thorough DevOps experience. Always interested in the latest cutting-edge technologies, and recently started gaining deep knowledge and experience in the field of machine learning and artificial intelligence. My huge passion for technology motivated me to self-educate myself in these different technical fields, and the vision to the future keeps pulling me to develop myself continuously. Additionally, a pharmacist holds a doctoral degree (Ph.D.) in pharmacology from the University of Graz in Austria. Besides being a husband to a beautiful doctor, but not a father yet. To keep myself fit (though in the being time I am not really committed), swimming, table tennis, and cycling are my favorites. Occasionally I like to play some computer or board games. If You Are Working On Something That You Really Care About, You Don’t Have To Be Pushed. The Vision Pulls You. – Steve Jobs

Updated on October 19, 2020

Comments

  • Mohammed Noureldin
    Mohammed Noureldin over 3 years

    I am wondering where is NuGet.Config file located in Visual Studio 2017 project? 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). Does some one have any idea?

    Here is the file I am trying to achieve for my .Net Core project:

    <?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>
    
  • Justin Emgarten
    Justin Emgarten about 7 years
    In Visual Studio 2017 open the solution, then go to tools > options > NuGet Package Manager > Package Source. You should see your sources listed.
  • Passenger
    Passenger over 6 years
    By default, VS2017 uses global Nuget.config located at path C:\Users\yourusername\AppData\Roaming\NuGet\Nuget.config
  • Pure.Krome
    Pure.Krome over 5 years
    I think you've misunderstood the question. The question is about where do you place the nuget.config file (which lists all the servers which hold available nugets to download). It's not asking which file lists the installed nugets for your project.
  • cadull
    cadull over 5 years
    Try not to confuse a nuget.config file with a .nuget folder. NuGet (v3.4.3 and later) silently ignores the entire configuration file if it contains malformed XML (mismatched tags, invalid quotation marks, etc.). This is why it's preferable to manage setting using nuget config ref. It is working at solution level in VS2017 for me.
  • S.Serpooshan
    S.Serpooshan over 5 years
    @Pure.Krome agree, but it is exciting that the man posted this answer which you think he misunderstood the question, is in fact the man asked the question! ;D
  • Pure.Krome
    Pure.Krome over 5 years
    /me hides away, embarassed.
  • joehanna
    joehanna over 4 years
    If you plan to use a CI like Microsoft AppCenter (appcenter.ms) - then it is expecting Nuget.config to the be in the Solution root.
  • Manuzor
    Manuzor about 4 years
    Since it was confusing to me at first, I'd like to clarify: The order listed here is the order in which nuget loads its settings. Later steps potentially override previous settings. So when you specify --configfile ist still reads the default file, the machine-level file etc. But then NuGet considers these options bottom-to-top, i.e. the --configfile wins vs. the user-level file etc.
  • tarekahf
    tarekahf about 2 years
    I am not sure why the file NuGet.config was empty when I did the setup on my work laptop, but it was configured properly on my personal laptop. I really wanted to know how this file gets created and under which process? Is it part of the MSBuild Tool Install or part of the NuGet vscode extension install?
  • tarekahf
    tarekahf about 2 years
    I am not sure why the file NuGet.config was empty when I did the setup on my work laptop, but it was configured properly on my personal laptop. I really wanted to know how this file gets created and under which process? Is it part of the MSBuild Tool Install or part of the NuGet vscode extension install?