Search code examples
visual-studionuget.net-corenuget-package-restorevisual-studio-mac

Unable to restore nuget packages in Visual Studio for Mac & dotnet core with slow (Bolivian) internet


I'm having problem restoring packages for a dotnet core 2.0 project here in Bolivia. Back home in The Netherlands I have no problems restoring the packages, but here it breaks.

I'm getting a lot of errors like:

Failed to download package 'System.Linq.4.1.0' from
'https://api.nuget.org/v3-flatcontainer/system.linq/4.1.0/system.linq.4.1.0.nupkg'.
An error occurred while sending the request
  Error: SecureChannelFailure (Unable to write data to the transport connection: Cannot access a disposed object.
  Object name: 'System.Net.Sockets.Socket'..)
  Unable to write data to the transport connection: Cannot access a disposed object.
  Object name: 'System.Net.Sockets.Socket'..
  Cannot access a disposed object.
  Object name: 'System.Net.Sockets.Socket'.
Unable to load package 'System.Linq'.

When I try to wget this file I'm getting between 400 KB/s and 3 MB/s.

I'm thinking it's nuget restoring the packages in parallel and that causes the Hostel internet to be fully used? I have tried it in different Hostels/Cafe's here, and I'm getting the same problems. When I Remote Desktop into my home server in the Netherlands and restore the packages for the same project it's all going well.

What are my options here? I tried googling this problem for a while, but I haven't found a solution yet.

Thanks!

Jorik


Solution

  • I cannot help with the networking problem but you may be able to reduce the amount of NuGet packages that are being downloaded by Visual Studio for Mac as a possible workaround. This can be done for a .NET Core 2.0 project by using the NuGet fallback folder:

    /usr/local/share/dotnet/sdk/NuGetFallbackFolder/
    

    The fallback folder holds many NuGet packages that are used by .NET Core 2.0 by default. This folder should be created if you install the .NET Core SDK.

    Using the above folder will prevent a lot of NuGet packages from being downloaded.

    You can either add it directly as a NuGet package source or edit your ~/.config/NuGet/NuGet.Config file and add the fallback folder as follows:

    Alternatively you could add an explicit fallback folder into your ~/.config/NuGet/NuGet.Config file:

    <fallbackPackageFolders>
      <add key="DotNetCore2FallbackFolder" value="/usr/local/share/dotnet/sdk/NuGetFallbackFolder" />
    </fallbackPackageFolders>
    

    Visual Studio for Mac would need to be restarted. Also check that the folder exists.

    Note that due to another bug Visual Studio for Mac will still download a few NuGet packages when restoring a .NET Core project.