Search code examples
c#.netexcelteamcityepplus

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


We are using EPPlus to generate Excel documents. Code builds successful in my local system but it is failing when we build through TeamCity and getting below error -

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

I have tried Google to find the solution but all in vain. My Project target framework is 4.5.2 and I have also added System.Core and WindowsBase. I have also added namespace "using OfficeOpenXml" EPPlus is added through Nuget Package.


Solution

  • If you have any packages installed using NuGet, then you need to add a NuGet Installer build step in your build configuration before the actual build command, using the solution file which references the NuGet packages you need. This step is what causes TeamCity to download any NuGet packages that are required that it doesn't have installed.