简体   繁体   English

NuGet软件包还原失败并显示错误消息-无法构建解决方案

[英]NuGet Package Restore fails with error message - can't build solution

I recently ran into an issue with an old Visual Studio solution/project where I couldn't build the solution because NuGet was reporting the following: 我最近遇到了一个旧的Visual Studio解决方案/项目的问题,由于NuGet报告了以下内容,因此无法构建该解决方案:

"Unable to find version '0.1.0' of package 'ElmahJS' on <NuGet feed>..."

How can I resolve this issue? 我该如何解决这个问题?

For older projects, I've found that this error may actually mean what it says - the Nuget package no longer exists on Nuget. 对于较旧的项目,我发现此错误实际上可能代表它的意思-Nuget包不再存在。

In some cases, the package reference you need may already exist in the solution - ie the package restore is not necessary to restore the reference needed. 在某些情况下,您所需的软件包参考可能已存在于解决方案中-即,还原软件包对于恢复所需的参考不是必需的。

In that case, open the packages.config file in the root of the project, and comment out the line(s) with the problematic packages. 在这种情况下,请打开项目根目录中的packages.config文件,并注释掉有问题的软件包所在的行。

If the NuGet package doesn't exist AND the corresponding reference doesn't exist in the checked-in solution, then you may have to go on a hunt outside of Nuget to find if the package still exists (ie Google). 如果NuGet包不存在对应参考并不在签入的解决方案存在,那么你可能去的NuGet的狩猎外面寻找,如果包仍然存在(即谷歌)。

If it no longer exists anywhere, replace with a suitable alternative. 如果它不再存在,请替换一个合适的替代方法。

seems like your pakage is no loge exists you can update your package from package manager console using following command 似乎您的包装没有日志,您可以使用以下命令从软件包管理器控制台更新软件包

# Updates a specific package using its identifier, in this case ElmahJS
Update-Package ElmahJS

if above dont work than try 如果以上不起作用比尝试

# Uninstalls the Elmah package and all its unused dependencies
Uninstall-Package Elmah -RemoveDependencies 

# Add the Elmah package to the default project as specified in the console's project selector
Install-Package Elmah

for details check here : https://docs.microsoft.com/en-us/nuget/tools/package-manager-console#updating-a-package 有关详细信息,请参见此处: https : //docs.microsoft.com/zh-cn/nuget/tools/package-manager-console#updating-a-package

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

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