Search code examples
.netnugetnuget-package-restoredotnet-cli

Restoring nuget packages of project with the http version of nuget.org using the dotnet cli


I am trying to dotnet restore my .net core project, however i cannot access https://api.nuget.org/* from my current workstation (so the command just times out), accessing http://api.nuget.org/* however is possible.

Is there a way to make the dotnet cli use the http version of nuget.org?


Solution

  • You can create a NuGet.Config file in your repository (or create it using dotnet new nugetconfig) and add the feed like this:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
     <packageSources>
        <clear />
        <add key="nuget.org" value="http://api.nuget.org/v3/index.json" protocolVersion="3" />
     </packageSources>
    </configuration>
    

    You can also update your global NuGet.Config file to match. It is located in ~/.nuget/NuGet/NuGet.Config on *nix and %APPDATA%\NuGet\NuGet.Config on Windows.