SolvedSpecFlow Could not find a reference to SpecFlow in project because of SpecFlowSingleFileGenerator

SpecFlow Version:

  • 3.0
  • 2.4
  • 2.3
  • 2.2
  • 2.1
  • 2.0
  • 1.9

Used Test Runner

  • SpecFlow+Runner
  • MSTest
  • NUnit
  • Xunit

Version number:
3

Visual Studio Version

  • VS 2019
  • VS 2017
  • VS 2015

Are the latest Visual Studio updates installed?

  • Yes
  • No

.NET Framework:

  • >= .NET 4.5
  • before .NET 4.5
  • .NET Core 2.0
  • .NET Core 2.1
  • .NET Core 2.2
  • .NET Core 3.0

Test Execution Method:

  • Visual Studio Test Explorer
  • TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK
  • Command line – PLEASE SPECIFY THE FULL COMMAND LINE

<SpecFlow> Section in app.config or content of specflow.json

	<specFlow>
	</specFlow>

Issue Description

When I edit my scenarios, I'm getting errors like :

#error Could not find a reference to SpecFlow in project 'projectname'.
#error Please add the 'TechTalk.SpecFlow' package to the project and use MSBuild generation instead of using SpecFlowSingleFileGenerator.
#error For more information see https://specflow.org/documentation/Generate-Tests-from-MsBuild/

My teammates have no problem with this. I have already recloned repo, reinstalled my VS and nothing helps...Did someone meet such issue?

46 Answers

✔️Accepted Answer

Hello

We were facing the same problem while using Specflow for Visual Studio 2017 and 2019 with an older package reference. Due to internal pipelines we cannot fully migrate to newer versions of specflow yet. We were not able to generate any codebehind for specflow feature files after latest Specflow update. It seems that this happened due to an update yesterday May 8th.

A workaround we did in our dev team was:

Our application is a NET Core 2.0 with output type Console application.

Here is our App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
    <unitTestProvider name="MsTest" />
  </specFlow>
</configuration>

and csproj sample

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="App.config">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <None Update="Services\Cache\Features\SpecFlowFeature1.feature">
      <Generator>SpecFlowSingleFileGenerator</Generator>
      <LastGenOutput>SpecFlowFeature1.feature.cs</LastGenOutput>
    </None>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
    <PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
    <PackageReference Include="NUnit" Version="3.11.0" />
    <PackageReference Include="SpecFlow" Version="2.2.1" />
    <PackageReference Include="StackExchange.Redis" Version="1.2.6" />
    <PackageReference Include="System.Net.Http" Version="4.3.0" />
  </ItemGroup>
   ....
</Project>

@orestsyniavskyi Have a go to check if this could solve your problem

Other Answers:

I have the same issue. Everything was working fine until today. We're using package references and net472;
<PackageReference Include="SpecFlow" Version="2.4.0" />

#error Could not find a reference to SpecFlow in project '[Name]'.
#error Please add the 'TechTalk.SpecFlow' package to the project and use MSBuild generation instead of using SpecFlowSingleFileGenerator.
#error For more information see https://specflow.org/documentation/Generate-Tests-from-MsBuild/

Thanks, @juniormayhe, it works now. Problem is with new version of specflow extension.

Related Issues:

23
SpecFlow Specflow Test not appearing in Test Explorer
@chaturvediankit I think i just needed to include the SpecFlow.Tools.MsBuild.Generation That seems t...
14
SpecFlow Could not find a reference to SpecFlow in project because of SpecFlowSingleFileGenerator
Hello We were facing the same problem while using Specflow for Visual Studio 2017 and 2019 with an o...
230
mocha timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
just add in your package.json under scripts Then you can just run I'm getting the following error wh...
122
mocha Error: Resolution method is overspecified.
async functions (babel) with done also break. This: will result in an error Error: Resolution method...
98
mocha mocha 4 doesn't exit unlike mocha 3
Other than providing a quick fix (use --exit) I do agree they left the core issue of finding the fau...
77
mocha Async test fails with timeout instead of assertion error
I ran into a similar problem and eventually realized you shouldn't use done when testing asynchronou...
48
mocha Cannot find module 'tap', but tap isn't listed as a dependency
It's something I run into as well I think that 's because you run a test from your node_modules ...
23
mocha Error: Cannot find module './options' (fresh start)
@damienromito I have experienced this issue soooooo many times with Mocha 3.x it is just routine to ...
21
mocha this.timeout() inside describe() doesn't work for me
For posterity you can use arrow functions and set the timeout like this: This below JS snippet is fr...
20
mocha Deprecate --watch
All the proposed alternatives here seem to ignore the main point: Mocha's --watch is so useful becau...
20
mocha Vulnerability Advisory flaggs 1 high vulnerability in js-yaml for mocha@6.1.3
@boneskull why is mocha doing js-yaml: 3.13.0,? If you you had js-yaml: ^3.13.0 there would be nothi...
19
karma Node v4.2.6 - FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
If others are having this issue still hey there - i'm hitting the following error after upgrading to...
15
karma Karma 1.6 breaks Headless support for Chrome
Got into this with karma v1.7.0 Google Chrome 59.0.3071.86 Karma version (output of karma --version)...
13
Behat 3.4.0 breaks the ability to run individual tests
On a side note Update + quick fix This is a long standing issue which is affecting many users It has...
13
mocha Data-generated test cases (parameterized tests)
With all my respect the proposed solution sucks First of all the error message will be expected fals...
11
karma Karma 0.13.19 taking long time to complete when run via gulp
I am also seeing this on version 1.1.1. I am opening a new ticket as this seems to be fallout from #...
11
mocha Add a way of a programmatically skipping a test
How about this? I have a code where certain tests will always fail in CI environment I would like to...
8
mocha Mocha configuration with webpack 2 Tree Shaking
I did this: and then NODE_ENV=test mocha.. - did the trick for me. With Webpack 2 we get a built-in ...
4
mocha Cannot combine --delay and --watch and --require hook
@Download I have no babel experience per se but your repo problem would seem a little more basic tha...
4
mocha To specify watching directories with mocha-cli
Any progress on this? @dennisbaskin I cant find the option --watch-dirs in the docs where is that fr...
3
mocha Possible Bug with mocha new configuration file
Hi I had a similar issue to this happen to me earlier today Hi I need help with an issue with mocha ...
3
Pester v5: Discussion
After writing this I am not 100% sur if this should be in this thread Although the -Passthru object ...
4
godog write output to a file
We have decided to implement this: Where the progress formatter would write to stdout and the junit ...
3831
axios Axios catch error returns javascript error not server response
I have exactly the same environment Try this: Modify from console.log(error) to console.log(error.re...
731
scrapy ' error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 '
@euler16 for scrapy with Python 3 you'll need with Python 2 you'll need I wanted to install scrapy i...
684
laradock Mysql. The server requested authentication method unknown to the client [caching_sha2_password]
alter user 'username'@'localhost' identified with mysql_native_password by 'password'; would fix it....
517
react navigation screenIsActive prop / componentDidFocus event for TabNavigator items
It probably makes sense to add lifecycle hooks to screens In one of my Tabs i need to load Data from...
474
meteor [1.4.2.1] Error: ENFILE: file table overflow
I was getting the same after an upgrade to macOS Sierra Turns out macOS have a harsh limit on number...
423
ipython Last jedi release (0.18.0) is incompatible with ipython (7.19 and 7.18 tested); reason - column arg was deprecated, and now removed
As a temporary fix for anyone just trying to get things working again: It would be really nice if yo...
397
material ui Module not found: Can't resolve 'material-ui-icons/Menu' Martial Next
For anyone else experiencing this issue: npm install @material-ui/icons https://www.npmjs.com/packag...
395
laravel dompdf (1/1) ErrorException Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically
This happens because you are namespacing the wrong PDF class You are namespacing Barryvdh\DomPDF\PDF...
378
webpacker localIdentName option moved in css-loader configuration
I faced same issue after upading css-loader but I solved it If you check css-loader readme ...
364
react navigation Send data back from child screen?
@itswaze You can do something along these lines to pass back from the child screen ...
358
react navigation How to goBack from nested StackNavigator?
@dhruvparmar372 According to the NOTE in the doc a navigator's navigation prop may not have the help...
352
axios POST request works in Browser but not on Node
This might be considered a duplicate of #789 I was able to use the form-data package with Axios in n...
317
react navigation Best pattern for a 'Save' button in the header
Try setting your component instance's handleSave function as a navigation state parameter after the ...
310
DefinitelyTyped [@types/react] RefObject.current should no longer be readonly
It's not It'a intentionally left readonly to ensure correct usage even if it's not frozen ...
306
react native navigation [V3][Android] FATAL EXCEPTION: create_react_context
OK after a good night of sleep I've found why I was having this issue In the MainApplication.java I ...
303
ts node Custom typings not working with ts-node 8.0.2
When using with ts-node you have to add --files flag After updating to ts-node version 8.0.2 the cus...
294
ohmyzsh compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew
Per #9602 (comment) brew cleanup fixed it for me I am using Apple M1 When I added this line: export ...
292
laradock SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
+1 I'm having the same problem here. Info: Docker version ($ docker --version): Docker version 17.12...
289
vagrant vagrant box update - Fails with 404 Not Found error
A workarround to add in your Vagrantfile: Vagrant version Host operating system Ubuntu 16.04.3 LTS G...
263
vagrant vagrant --help displays a rubygems error
To fix this error: Vagrant version Host operating system Expected behavior vagrant and vagrant --hel...
262
date fns Can't resolve 'date-fns/_lib/format/longFormatters'
You probably forgot to install date-fns or Code: import DateFnsUtils from '@date-io/date-fns'; ...
259
virtualenv Error creating virtualenv with python3.6
The original poster's problem is due to not having the 'python3.6-venv' package installed ...
252
provider A Product was used after being disposed. flutter: Once you have called dispose() on a Product, it can no longer be used.
Oh I see what you're doing Don't: DO: i have a ChangeNotifireProvider that such that i do pushReplac...
248
react navigation Reset to nested route, "There is no route defined for..."
A quick workaround (not heavily tested): set the key property to null on your action. ...
238
axios Adding headers to axios.post method
Edit: I had to add Authorization to allowed headers in my CORS filter @jffernandez I'm having the sa...
231
axios Adding Retry Parameter
@mericsson I am too in need of exponential backoff when retrying I've put together the following whi...