Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using nuget packages on machine with no internet

I have a .net core intranet web app which uses certain nuget packages. I have two machines, my local computer with internet and a test machine with no connection to outside internet. The app works fine on my computer. All the nuget packages are locally stored and referred by the web app.

When I try to build the app on test machine, I am getting the following error

 C:\Program Files\dotnet\sdk\3.0.100\Nuget.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json

What process is actually looking for service index from outside url? Of course it cannot find because there is no internet. No proxies involved so nothing to put in nuget.config

All the packages are locally stored. What can I do to resolve this issue?

Thank you

like image 770
blue piranha Avatar asked Oct 17 '25 13:10

blue piranha


2 Answers

  1. You’ll need a local folder to keep all your local NuGet packages..

  2. Then download the NuGet packages you wish to be able to use offline into this folder. Packages can be downloaded from nuget.org.

  3. Once you are logged in, search for the packages you require and click the ‘Download’ link in the left hand menu of each.

  4. Once you have successfully downloaded the .nupkg files you require into your local repository folder, head into Visual Studio and open the NuGet Settings dialog via Tools > NuGet Package Manager > Package Manager Settings. Click the Package Sources tab within the settings dialog, followed by the ‘plus’ icon in the top left to add a new package source.

  5. Enter the Name and Source of your local repository. The name can be any string and will be the name displayed in the NuGet Package Manager within Visual Studio.

  6. Now that you have added the local package source, you will be able to use your offline local repository from within Visual Studio in the usual way, either via the Console or via the Package Dialog, by selecting it from the Package Source menu, without the need for an active internet connection.

like image 50
cengiz sevimli Avatar answered Oct 20 '25 17:10

cengiz sevimli


Late to the party, but as the Answer was relying on Visual Studio, I want to update with the results of my attempts to get it running without any IDEs installed on the windows machine:

  1. Go to the nuget.config file (located on in %APPDATA%\NuGet\NuGet.Config)

  2. Change to the local location of all required Package Files and remove the reference to the Web repo.

  3. The trailing Backslash was essential

  4. Save

  5. Enjoy Life

My nuget.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuGet" value="c:\OfflineDependies\" />
  </packageSources>
</configuration>

possible improvements: Seems like there is a possibility to chnage the nuget settings on a project level. Bit I didn't dig in to follow that route.

like image 33
Robert Reiher Avatar answered Oct 20 '25 15:10

Robert Reiher