简体   繁体   English

NuGet安装软件包不起作用。 如何获取更多详细信息以帮助调试为什么失败?

[英]NuGet install-package doesn't work. How can I get more verbose information to help debug why this is failing?

A collegue is trying to install a nuget package into a simple default c# web application. 一位同事正在尝试将nuget软件包安装到简单的默认c#Web应用程序中。 It fails almost instantly. 它几乎立即失效。

Is there an argument I can provide to Install-Package <some nuget package> in the Visual Studio Package Manager Console to get some verbose information to help debug why the installation fails? 我可以在Visual Studio程序包管理器控制台中为Install-Package <some nuget package>提供参数,以获取一些详细信息来帮助调试安装失败的原因吗?

Error Message: 错误信息:

An error occurred while retrieving package metadata for '' from source 'MyGet'. 从源“ MyGet”中检索“”的程序包元数据时发生错误。

Info: Visual Studio: V2015 NuGet extension: 3.4.4.1321 Nuget package source: MyGet 信息:Visual Studio中: V2015的NuGet扩展: 3.4.4.1321 NuGet包来源:MyGet

Sample NuGet.config file found in the root directory of the solution: 在解决方案的根目录中找到示例NuGet.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="MyGet" value="https://www.myget.org/F/<our package>/api/v2" /> 
  </packageSources>
</configuration>

For myself, I can install the package fine. 对于我自己,我可以很好地安装该软件包。 In fact, we have 5 packages in this MyGet public repo and I just installed 2 of the packages, just then .. when I test this out (again) before I created this SO question. 实际上,我们的MyGet公共仓库中有5个软件包,而我刚安装了其中的2个软件包,就在创建这个SO问题之前(再次)进行测试时。

Anyone have a suggestion, please? 有人有建议吗?

UPDATE 更新

As stated above, this is using the PACKAGE MANAGER CONSOLE, not the CLI. 如上所述,这是使用PACKAGE MANAGER CONSOLE,而不是CLI。

Using the -verbosity detailed in the PMC this is what happens.. 使用PMC中-verbosity detailed-verbosity detailed ,就会发生这种情况。

PM> install-package xunit -verbosity detailed
Install-Package : A parameter cannot be found that matches parameter name 'verbosity'.
At line:1 char:23
+ install-package xunit -verbosity detailed
+                       ~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Install-Package], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

You could try adding the -Verbose parameter to your PowerShell command. 您可以尝试将-Verbose参数添加到PowerShell命令。

 install-package xunit -verbose

You can also try looking at the $error object to see if that has more information, such as an exception callstack. 您也可以尝试查看$ error对象,以查看是否具有更多信息,例如异常调用堆栈。

$error.Exception.StackTrace

The above may or may not give you more information. 以上内容可能会或可能不会为您提供更多信息。

You can use the -Verbose switch in the PowerShell-enabled Package Manager Console to get more details. 您可以在启用PowerShell的Package Manager控制台中使用-Verbose开关来获取更多详细信息。

To rule out client-connectivity issues to MyGet, can you try diagnosing client connectivity to the feed? 要排除与MyGet的客户端连接性问题,您可以尝试诊断客户端与Feed的连接性吗?

https://www.myget.org/F/<feedIdentifier>/api/v2

Try using Fiddler to retrieve a specific package from the feed on that user's machine using URL format: 尝试使用Fiddler使用URL格式从该用户计算机上的Feed中检索特定的软件包:

https://www.myget.org/F/<feedIdentifier>/api/v2/package/<packageId>/<packageVersion>

If it is a private feed, you'll need to authenticate your request, eg using the pre-authenticated v2 endpoint: 如果是私人供稿,则需要对请求进行身份验证,例如使用预先身份验证的v2端点:

https://www.myget.org/F/<feedId>/auth/<apiKey>/api/v2/package/<packageId>/<packageVersion>

Clearing the NuGet client's HTTP cache may also prove useful if something is corrupt in the cache. 如果缓存中有损坏,清除NuGet客户端的HTTP缓存也可能很有用。 You can clear it using the NuGet commandline command: 您可以使用NuGet命令行命令清除它:

nuget.exe locals http-cache -clear

If the package is already in local cache, then the NuGet client will resolve it from local cache instead. 如果程序包已经在本地缓存中,则NuGet客户端将改为从本地缓存中解析它。 It may be that the package in local cache is corrupt, in which case you can use the following NuGet commandline command: 可能是本地缓存中的软件包已损坏,在这种情况下,您可以使用以下NuGet命令行命令:

nuget.exe locals all -clear

Finally, it may also be worth looking at the nuget.config hierarchy. 最后,值得一看的是nuget.config层次结构。 The most-local nuget.config will inherit config settings from higher up the chain (eg machine-wide settings), one of which is the <disabledPackageSources> element. 最本地的nuget.config将从上级链继承配置设置(例如,机器范围的设置),其中之一是<disabledPackageSources>元素。 To ensure this one is not acting up here, add the following to your most-local nuget.config and retry: 为确保此功能不会在这里起作用,请将以下内容添加到您最本地的nuget.config中,然后重试:

<disabledPackageSources>
  <clear />
</disabledPackageSources>

If none of the above helps you in resolving the issue, feel free to use the nuget commandline (nuget.exe) with -verbosity detailed as it may provide more details, such as the actual HTTP requests being made. 如果上述方法均不能帮助您解决问题,请随时使用带有-verbosity detailed的nuget命令行(nuget.exe),因为它可能会提供更多详细信息,例如发出的实际HTTP请求。

Also, make sure you use the latest versions of the NuGet client tools (available here ) 另外,请确保使用最新版本的NuGet客户端工具( 在此处可用)

Looks like you are running into http://blog.myget.org/post/2016/02/21/Two-of-my-packages-are-treated-as-one-Help!.aspx . 看起来您正在遇到http://blog.myget.org/post/2016/02/21/Two-of-my-packages-are-治疗-作为一个帮助.aspx There is a 0.7.0-dev and a 0.7-dev version of the package on the feed, which NuGet treats as the same version. 订阅源上有一个0.7.0-dev和0.7-dev版本的软件包,NuGet将该版本视为相同版本。

The solution is to remove one of these two packages. 解决方案是删除这两个软件包之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM