"The type or namespace name 'OfficeOpenXml' could not be found" 错误

"The type or namespace name 'OfficeOpenXml' could not be found" error

我们正在使用 EPPlus 生成 Excel 文档。代码在我的本地系统中构建成功,但是当我们通过 TeamCity 构建并出现以下错误时它失败了 -

error CS0246: The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)

我已经尝试 Google 找到解决方案,但都是徒劳的。我的项目目标框架是 4.5.2,我还添加了 System.Core 和 WindowsBase。我还添加了命名空间 "using OfficeOpenXml" EPPlus 是通过 Nuget 包添加的。

如果您使用 NuGet 安装了任何包,那么您需要在实际构建命令之前的构建配置中添加 NuGet 安装程序构建步骤,使用引用您需要的 NuGet 包的解决方案文件。此步骤导致 TeamCity 下载它尚未安装的任何所需的 NuGet 包。

我通过手动删除和添加 EPPlus 引用解决了这个问题。