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

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

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

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

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


当前回答

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

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

其他回答

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

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

对我来说,我把NuGet.exe从3.4升级到4.9,因为3.4不理解如何恢复。net Core的包。

有关详细信息,请参见teamcity的dotnet恢复与nuget恢复

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

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

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选项。

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

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.