Visual Studio 在线无法构建项目,因为 Entity Framework 引用无法解析

Visual Studio Online cannot build project due to Entity Framework reference cannot be resolved

我该怎么做才能修复这个版本? Entity Framework 已通过 NuGet 添加到此项目。

所有项目在本地系统上编译都没有问题。但是在 Visual Studio Online 上构建失败。

通过打开诊断日志记录,我能够追踪到这个导致我的构建失败的警告:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "EntityFramework.SqlServer". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

我只需在解决方案资源管理器中右键单击解决方案并select启用 NuGet 包还原即可解决此错误。

这为我的解决方案添加了更多文件并修改了一些项目文件。然后构建服务器可以在构建时恢复包,最后很高兴。

不要 右键单击​​该项目并选择 "Enable NuGet Package Restore"。这是 "old way" 根据 Nuget Docs 进行包恢复。

默认情况下,包恢复应该作为构建过程的一部分进行。如果不是(似乎是这种情况),则您遇到了不同的问题,但没有足够的信息来说明是什么。