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

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

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

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

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


当前回答

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

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

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

希望它能起作用…

其他回答

回答这个问题有点晚了,但似乎这将增加价值。看看这个错误——它似乎发生在CI/CD管道中。

运行“dotnet build”就足够了。

dotnet构建

Dotnet构建默认运行“还原”。

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

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

另外,如果你碰巧使用Dropbox,检查文件名是否冲突,在你的回购中搜索并删除所有冲突的文件。

如果您移动了文件,可能会发生这种情况。

当您的构建工具没有设置为对设置为使用PackageReference vs packages的项目进行恢复时,会发生此问题。配置和主要影响Net Core和Netstandard新风格的项目。

当你打开Visual Studio并进行构建时,它会为你解决这个问题。但是如果您使用自动化、CLI工具,就会遇到这个问题。

这里提供了许多解决方案。但你只需要记住,你需要强制还原。在某些情况下,在构建之前使用dotnet还原。如果使用MsBuild构建,只需在命令中添加/t:Restore switch。

总之,您需要了解为什么恢复不能被激活。坏的nuget源或丢失恢复操作,或过时的nuget.exe,或以上所有。

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

dotnet restore

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