tulipe
tulipe

Reputation: 746

Offline Nuget Packages

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 path and yes the package is not there; isn't Nuget Package added by default? If not, from where I can add it?

Upvotes: 12

Views: 48995

Answers (4)

ΩmegaMan
ΩmegaMan

Reputation: 31721

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.

So, I did not have to do a nuget install Newtonsoft.json -source ... type command on each failed package, as mentioned in other posts.

Upvotes: 22

suhail salim
suhail salim

Reputation: 19

manually dowload from nuget.org package with extension NUPKG file,and copy paste that into (C:\Program Files (x86)\Microsoft SDKs\NuGetPackages) relative path OR RUN CMD COMMAND:

dotnet add projectpath package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore --version 6.0.0

Upvotes: 1

Emil
Emil

Reputation: 6921

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.

Upvotes: 7

Leo Liu
Leo Liu

Reputation: 76910

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.

Upvotes: 17

Related Questions