0
votes

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.

2
VS menu Tools > Extensions and Updates > Updates and check if there is no updates for NuGet Package Manager. Install the latest version, - Nivas Pandian
The error says "The remote name could not be resolved: 'api.nuget.org'". This means your internet isn't working correctly. - zivkan
@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

2 Answers

1
votes

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.

0
votes

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.