问题描述
当我尝试使用以下命令在 Visual Studio 2017 中安装包时,
When I tried to install the Package in Visual Studio 2017 using below command,
PM> Install-Package Microsoft.IdentityModel -Version 7.0.0
我收到以下错误
尝试为项目Portal.System"收集包Microsoft.IdentityModel.7.0.0"的依赖信息,目标是.NETFramework,Version=v4.0"
Install-Package:从源nuget.org"检索Microsoft.IdentityModel.7.0.0"的包元数据时出错.
Install-Package : An error occurred while retrieving package metadata for 'Microsoft.IdentityModel.7.0.0' from source 'nuget.org'.
发送请求时出错.
无法解析远程名称:'api.nuget.org' At line:1 char:1
error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org' At line:1 char:1
- 安装包 Microsoft.IdentityModel -Version 7.0.0
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException, NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
我该如何解决这个问题.
How can I fix this issue.
推荐答案
同意 zivkan,这个问题可能与您使用 VS2017 时的 Internet 连接有关.
Agree with zivkan, this issue could be related to Internet connection when you're using VS2017.
特别是您需要检查您是否可以通过 IE 浏览器访问 nuget.org
网站.我认为这个问题表明您的 DNS 提供商
有问题.请检查这一点并修复连接.
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.
另外:如果您在代理后面使用 nuget.org,有关 nuget.config 可能会有所帮助.
In addition: If you're using nuget.org behind proxy, some details about the nuget.config may help.
这篇关于尝试在 .Net 中安装包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!