简体   繁体   English

Visual Studio NuGet无法还原包

[英]Visual Studio NuGet Cannot Restore Packages

I have a large project that has about a dozen dependencies. 我有一个大型项目,它具有大约十二个依赖项。 I have tried to install them all but ran into an error from VS. 我试过全部安装,但是从VS遇到错误。 I am using Visual Studio 2015 我正在使用Visual Studio 2015

"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'." “尝试还原软件包时发生错误:无法找到软件包'Lucene.Net.Core'的版本'3.0.3.1'。”

Now I have a solution which I can use that is by the same name as this package, but VS refuses to let me updates, remove, or change ANYTHING related to these packages and asks that I restore the packages. 现在,我有一个可以使用的解决方案,该解决方案的名称与此程序包相同,但是VS拒绝让我更新,删除或更改与这些程序包相关的任何内容,并要求我还原这些程序包。 I am entirely lost here friends, what should I do? 我在这里完全迷失了朋友,该怎么办?

PS the two sources I am using for my package sources are: PS:我用于软件包源的两个源是:

https://www.nuget.org/api/v2/ https://www.nuget.org/api/v2/

https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/ https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/

The same error occurs for Lucene.Net.Contrib, pstsdk.net, and various packages. Lucene.Net.Contrib,pstsdk.net和各种程序包会发生相同的错误。

One thing to check for is if your project is built on a version of the NET framework that is less than or equal to the target framework the package has. 要检查的一件事是您的项目是否基于小于或等于程序包所具有的目标框架的NET框架版本构建。

If your project is a NET 4.5 based project, but the nuget package has a NET 4.5.2... then the package manager will error out. 如果您的项目是基于NET 4.5的项目,但是nuget软件包具有NET 4.5.2 ...,则软件包管理器将出错。

"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'." “尝试还原软件包时发生错误:无法找到软件包'Lucene.Net.Core'的版本'3.0.3.1'。”

When I use the packages sources which you provided, I found that only two versions (4.8.0 & 4.9.0) of package"Lucene.Net.Core" not have the version '3.0.3.1'. 当我使用您提供的软件包源时,发现只有两个“ Lucene.Net.Core”软件包版本(4.8.0和4.9.0)没有版本“ 3.0.3.1”。

Pay Attention: 请注意:

I noticed that the author of this package have updated this package at March 11, 2017(3/11/2017), and only release the version 4.8.0 & 4.9.0 . 我注意到此软件包的作者已于2017年3月11日(2017年3月11日)更新了此软件包,并且仅发布了4.8.0和4.9.0版本 So this must be the reason for NuGet restore failed. 因此,这一定是NuGet还原失败的原因。

在此处输入图片说明

Besides, you said: 此外,您说:

I have a solution which I can use that is by the same name as this package, but VS refuses to let me updates, remove, or change ANYTHING related to these packages 我有一个可以使用的解决方案,该解决方案的名称与此程序包相同,但是VS拒绝让我更新,删除或更改与这些程序包相关的任何内容

If you want to remove those error packages, you can try to use below command to force uninstall those packages: 如果要删除这些错误程序包,可以尝试使用以下命令强制卸载这些程序包:

Uninstall-Package Lucene.Net.Core -Force

Or you can delete this package from the package folder and delete the package list from the package.config. 或者,您可以从程序包文件夹中删除此程序包,并从package.config中删除程序包列表。

Then install the correct version of the packages. 然后安装正确版本的软件包。

要检查的另一件事是Visual Studio中的程序包管理器配置设置列出了公共nuget提要(以及是否也启用了提要)。

Although I was not able to get any of the posted answers to work, I ended up removing the project entirely and reinstalling VS, my project, and its dependencies. 尽管我无法获得任何发布的答案,但最终还是完全删除了该项目,然后重新安装了VS,我的项目及其依赖项。 This ended up working. 最终工作了。

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

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