Offline Nuget Packages

23,489

Solution 1

Visual Studio provides some common packages for us to use in the Microsoft SDKs\NuGetPackages folder when our computer doesn't have network.

The C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ folder is not means that the cache for the packages has been installed before from internet. So the package ProductionStackTrace will not add into this folder.

If you want to use this package without network, you need to download it when you have network. You can download it from the nuget.org.

Certainly, you can also add this package in to the Microsoft SDKs\NuGetPackages so that you can use it when you do not have a network. The add command line is:

nuget add <packagePath> -source <sourcePath> [options]

You can refer to the nuget Add reference for detail.

Hope this can help you.

Solution 2

for Visual Studio Mac, packages are copied into the path /Users/{username}/.nuget/packages

You can choose menu for Visual Studio->Preferences->Nuget->Sources and add a new source using this path and install already cached packages.

Solution 3

Unclear why this happened for my installation, but Visual Studio (VS 2022 preview at this time) had an offline location (good), but no package source to nuget.

This caused my build to fail on packages not found in the offline directory.

Hence I ended up adding a Package source in Visual Studio for Nuget as:

 nuget.org
 https://api.nuget.org/v3/index.json

Which then allowed VS to do a Restore of packages to succeed. Hence not having be to do a nuget install Newtonsoft.json -source ... command for each failed package.

Share:
23,489
tulipe
Author by

tulipe

Updated on December 03, 2021

Comments

  • tulipe
    tulipe over 2 years

    I need to install Nuget Package ProductionStackTrace, so I use the following command

    PM> Install-Package ProductionStackTrace
    

    But when I execute this command I get the following error

    The source at Microsoft Visual Studio Offline Packages [C:\Program Files (x86)\Microsoft SDKs\NuGetPackages] is unreachable.

    I checked the pathm and yes the package is not there; isn't Nuget Package added by default? If Not found from where I can add it?