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

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

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

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

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


当前回答

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

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

其他回答

试试这个(对我很管用):

以管理员身份运行VS 手动更新NuGet到最新版本 删除项目中所有的bin和obj文件。 重新启动和 重新编译

对我来说,当我做- dotnet恢复仍然发生错误。

我去了

1工具-> NuGet包管理器->包管理器设置->单击“清除所有NuGet缓存” 2 . dotnet恢复

解决问题。

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

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

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

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

dotnet restore

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

For me it turned out to be a nuget source credentials problem. I had recently changed my password for accessing a nexus server and visual studio was still using the old password when trying to access a nuget on that server through the windows credential manager. To fix it, I had to delete the entry for those outdated credentials in the credential manager and after, when I did a nuget restore, it prompted me for a password letting me enter the new password, which got saved in the credential manager again. You can access the credential manager from the cmd line using CmdKey.exe.