Error caused when trying to Installing package in .Net

百般思念 提交于 2019-12-13 03:54:11

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/57554185/error-caused-when-trying-to-installing-package-in-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!