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

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

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

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

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


当前回答

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.

其他回答

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

你可以去:工具> NuGet包管理器>包管理器控制台

然后运行:

点网还原

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

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

在我的例子中,它是。net项目,在DevOps windows-2019代理上进行构建。

解决方案:windows-2022可以构建。net6。

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

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