Search code examples
c#asp.net-core.net-corebddspecflow

SpecFlow.ExternalData is causing dotnet build to fail - cannot deploy to Azure DevOps


I have a problem with deploying the project to Azure DevOps because of the ExternalData. On my local machine, VS can build the project and tests work fine.

But, when I try to build the project with the command 'dotnet build' as it does on AzureDevops, it fails.

Error that I get:

Generation error: Message: Unable to load Excel file from pathToProject\Features\Something.xlsx': Could not load file or assembly 'ExcelDataReader, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa'. The system cannot find the file specified.

The same happens with CSV file, only it says CSVHelper instead of ExcelDataReader. I tried to install ExcelDataReader and nothing changed. I tried to manually copy ExcelDataReader.dll to my bin folder and then add it's dependency and still nothing changed.

Can someone please help? This is a vital part of our tests, to be able to use Excel or CSV files for test data.

EDIT:

Steps to reproduce:

There is a feature file that has a data source tag for the excel file:

@DataSource:ExcelFileName.xlsx
Scenario Outline: Get something
    Given I request a something with id "<Id>"
    Then the name of a something should be "<Name>"

If I build this locally on my machine in Visual Studio, it works and also test work. (If I do rebuild, or build).

If I enter the package manager console and do a command 'dotnet build' I get the error from above. This is the same command that is executed on AzureDevops.

Also, the excel file has: Build action: Content Copy to output directory: Copy always


Solution

  • This is fixed on SpecFlow side in the new version 3.9.52.