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

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

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

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

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


当前回答

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

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

我的解决方案是从使用VS Build任务切换到MSBuild任务。为单个项目使用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选项。

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

在我的例子中,错误是GIT存储库。它的名称中有空格,使我的项目无法恢复

如果这是您的问题,只需在克隆时重命名GIT存储库

git clone http://Your%20Project%20With%20Spaces newprojectname

我的问题是构建配置平台不匹配。一旦我把“任何CPU”改为“x64”,我就可以发布了。

前面提到过,但我只是想再次强调在路径中没有任何空间的重要性!这就是我想要的。我警告过你了。

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

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