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

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

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

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

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


当前回答

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

其他回答

在Azure DevOps中,当我在构建管道中设置“Visual Studio Build”任务来构建我的解决方案中的单个项目,而不是整个解决方案时,我在这个错误上浪费了几个小时。

这样做意味着DevOps要么不构建任何(或者可能是一些,我不确定是哪个)您构建的目标项目所引用的项目,因此这些项目不会生成它们的project.json.asset文件,这就导致了这个问题。

我的解决方案是从使用VS Build任务切换到MSBuild任务。为单个项目使用MSBuild任务可以正确地构建您正在构建的项目引用的任何项目,并消除此错误。

在visual studio 2017中,请执行以下步骤:

1)选择Tool=>Options=>NuGet Package Manager=> Package Sources然后取消勾选Microsoft Visual Studio Offline Packages Option。

2)现在打开工具=>NuGet包管理器=>包管理控制台。 3)在PM>中执行命令恢复dotnet。

希望它能起作用…

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

对于那些在Azure DevOps / VSTS环境中遇到类似问题的人:

C:\Program Files\dotnet\sdk\2.2.104\Sdks\ Microsoft.NET.Sdk\targets\ microsoft . packagedependencyresolve .targets(208,5):错误NETSDK1004: Assets file '…\obj\project.assets。Json没有找到。运行NuGet包还原生成此文件

Add /t:恢复到生成解决方案中的MSBuild参数。

我遇到过非常奇怪的经历!

我之前用GIT bash和GIT cmd-Line进行了克隆,遇到了上述问题。

后来,我用turtle - git进行了克隆,一切正常。

也许这是一个疯狂的答案,但尝试一次可能会节省你的时间!