我试图使用nopCommerce(这是写在。net核心),但当我想运行项目时,我面临52个错误告诉我运行一个nuget包恢复

Assets文件~\obj\project.assets。Json没有找到。运行NuGet包还原生成此文件。Nop.Web.MVC.Testsote

当我使用右键单击解决方案并选择恢复Nuget包时,我得到这样的消息:

所有的包都已经安装,没有什么要恢复的。

但是这52个错误仍然存在,在工具-> NuGet包管理器->管理解决方案的NuGet包中,解决方案上没有安装任何东西,我最近更新了我的VS2017到15.5.4


当前回答

当您的构建工具没有设置为对设置为使用PackageReference vs packages的项目进行恢复时,会发生此问题。配置和主要影响Net Core和Netstandard新风格的项目。

当你打开Visual Studio并进行构建时,它会为你解决这个问题。但是如果您使用自动化、CLI工具,就会遇到这个问题。

这里提供了许多解决方案。但你只需要记住,你需要强制还原。在某些情况下,在构建之前使用dotnet还原。如果使用MsBuild构建,只需在命令中添加/t:Restore switch。

总之,您需要了解为什么恢复不能被激活。坏的nuget源或丢失恢复操作,或过时的nuget.exe,或以上所有。

其他回答

造成这个缺陷的原因:你必须在文件资源管理器中删除注入的Nuget。 解决方案:一旦你在你的系统中删除了Nuget,然后从下面的位置删除。 选择工具=>选项=>NuGet包管理器=>包源,然后取消勾选Microsoft Visual Studio离线包选项

我没有在任何地方发现微软建议的删除“packages”文件夹的方法。

来源:解决包恢复错误

You may encounter build errors due to missing files, with a message saying to use NuGet restore to download them. However, running a restore might say, "All packages are already installed and there is nothing to restore." In this case, delete the packages folder (when using packages.config) or the obj/project.assets.json file (when using PackageReference) and run restore again. If the error still persists, use nuget locals all -clear or dotnet nuget locals all --clear from the command line to clear the global-packages and cache folders as described on Managing the global packages and cache folders.

当我在VS2017中创建一个lambda in dot net core时,我得到了错误。对我来说有用的是卸载项目并重新加载它。

我也遇到过类似的问题。原来我没有访问%APPDATA%\Local\Temp\NuGetScratch\lock

一旦我有访问,我可以运行nuget恢复,但一切都开始工作。

关闭和重新打开Visual Studio为我解决了这个问题,一旦我确定NuGet包已经按照这里张贴的其他答案恢复。

编辑:有时只是尝试重新构建就可以解决问题。