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

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

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

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

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


当前回答

对于那些在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参数。

其他回答

If this error occurs as part of a build in Azure DevOps (TFS) and your build already has a NuGet restore task, this error may indicate the NuGet restore task was not able to restore all packages, especially if you use a custom package source (such as an internal NuGet server). Adding /t:Restore;Build to the MSBuild Arguments seems to be one way to resolve the error, but this asks MSBuild to perform an additional NuGet restore operation. I believe this succeeds because MSBuild uses the custom package source configured in Visual Studio. A preferable solution is to fix the NuGet restore task.

为NuGet恢复任务配置一个自定义包源。

创建一个NuGet。列出所有包源(Microsoft Visual Studio Offline Packages, nuget.org和您的自定义包源)的配置文件,并将其添加到源代码控制中。 在Nuget还原任务下的Feeds to use:在我的Nuget .config中选择Feeds选项。 提供NuGet.config的路径。 从MSBuild任务中移除/t:Restore;Build选项。

更多信息可以在这里找到。

要修复工具> NuGet包管理器>包管理器控制台中的此错误,只需运行:

dotnet restore

出现此错误是因为dotnet cli最初没有创建所需的所有文件。执行dotnet还原会添加所需的文件。

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

在vs -2019 vs 16.4.0上添加WinForms Core 3.1项目(从项目模板中)并尝试开箱运行后看到了这一点。清理或重新构建整个解决方案不起作用。

我刚刚重新加载了我的解决方案。即文件/关闭解决方案,然后重新打开并重新构建它就解决了问题。

如果只是恢复NuGet包不工作,确保在工具->选项-> NuGet包管理器->通用下的包恢复,“允许NuGet下载丢失的包”是选中的。

然后恢复NuGet包再次或只是重建后删除obj和bin文件夹。