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

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

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

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

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


当前回答

我没有在任何地方发现微软建议的删除“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.

其他回答

当我得到这个错误时,对我有用的是添加一个全局变量。json文件,但这可能与使用Paket而不是Nuget有关。

在我的例子中,我在*中添加了以下内容。在“Clean”上完全删除obj和bin文件夹。显然,它就是罪魁祸首。摆脱了那个和中提琴,一切又开始运转了。现在我正在使用“清洁垃圾箱”扩展代替。希望这可以帮助任何遇到这个问题的人,上面提到的修复都不起作用。

<Target Name="SuperClean" AfterTargets="Clean">
    <!-- Remove obj folder -->
    <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
    <!-- Remove bin folder -->
    <RemoveDir Directories="$(BaseOutputPath)" />
</Target>    

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

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

我没有在任何地方发现微软建议的删除“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.

您将从“https://api.nuget.org/v3/index.json”获得所需的软件包。将此添加到包资源中。同时确保其他包暂时未选中。在“解决方案资源管理器”中单击“恢复原始包”