0

When I tried to install the Package in Visual Studio 2017 using below command,

PM> Install-Package Microsoft.IdentityModel -Version 7.0.0

I got the following error

Attempting to gather dependency information for package 'Microsoft.IdentityModel.7.0.0' with respect to project 'Portal.System', targeting '.NETFramework,Version=v4.0'

Install-Package : An error occurred while retrieving package metadata for 'Microsoft.IdentityModel.7.0.0' from source 'nuget.org'.

error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org' At line:1 char:1

  • Install-Package Microsoft.IdentityModel -Version 7.0.0
  •  + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
     + FullyQualifiedErrorId : NuGetCmdletUnhandledException, NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    

How can I fix this issue.

Pod Mo
  • 248
  • 2
  • 8
Renjith Krishnan
  • 2,446
  • 5
  • 29
  • 53
  • VS menu Tools > Extensions and Updates > Updates and check if there is no updates for NuGet Package Manager. Install the latest version, – Nivas Pandian Aug 19 '19 at 10:00
  • 2
    The error says "The remote name could not be resolved: 'api.nuget.org'". This means your internet isn't working correctly. – zivkan Aug 19 '19 at 12:15
  • @NivasPandian Starting from Visual Studio 2017, NuGet is no longer an extension in the Visual Studio Marketplace, and is bundled with Visual Studio through the installer. – zivkan Aug 19 '19 at 12:16

2 Answers2

1

Agree with zivkan, this issue could be related to Internet connection when you're using VS2017.

Especially you need to check if you can access nuget.org website by your IE browser. I think this issue indicates something is wrong with your DNS provider. Please check this point and fix the connections.

In addition: If you're using nuget.org behind proxy, some details about the nuget.config may help.

LoLance
  • 25,666
  • 1
  • 39
  • 73
0

Download latest nuget commandline util from https://www.nuget.org then run below command

nuget.exe locals -clear all

Restart your visual studio. this problem to occur on any system with a fresh installation of Windows/VS/tooling so likely a bug with their installers.

Nijin P J
  • 1,302
  • 1
  • 9
  • 15