Specflow: Version conflict - SpecFlow Visual Studio extension attempted to use SpecFlow code-behind generator 1.9, but project 'Test' references SpecFlow 2.1.

Created on 27 Jun 2019  Â·  14Comments  Â·  Source: SpecFlowOSS/SpecFlow

SpecFlow Version:

  • [x] 3.0
  • [ ] 2.4
  • [ ] 2.3
  • [ ] 2.2
  • [ ] 2.1
  • [ ] 2.0
  • [ ] 1.9

Used Test Runner

  • [ ] SpecFlow+Runner
  • [ ] MSTest
  • [x] NUnit
  • [ ] Xunit


Version number: 2.2 NUnit Test Adapter

Project Format of the SpecFlow project

  • [ ] Classic project format using packages.config
  • [ ] Classic project format using <PackageReference> tags
  • [x] Sdk-style project format

.feature.cs files are generated using

  • [ ] SpecFlow.Tools.MsBuild.Generation NuGet package
  • [x] SpecFlowSingleFileGenerator custom tool

Visual Studio Version

  • [ ] VS 2019
  • [ ] VS 2017
  • [x] VS 2015

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

  • [x] Enabled
  • [ ] Disabled

Are the latest Visual Studio updates installed?

  • [x] Yes
  • [ ] No, I use Visual Studio version <Major>.<Minor>.<Patch>

.NET Framework:

  • [x] >= .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:

  • [x] 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


Repro Project

Issue Description

Steps to Reproduce

Question

Most helpful comment

Thanks Stephen-Mc, I was able to get past the build errors after following your suggestions and also after reading the documentation. I had previously thought the documentation would only apply when opening older projects with existing SpecFlow tests (I was thinking that when starting with a new project everything would just work).

Below the is the process I followed to get going. This issue is now resolved for me, thanks again!

  1. Change the "_Enable SpecFlowSingleFileGenerator Custom Tool_" setting in VS Options to 'False'
  2. Create a new C# Class Library solution using .NET Framework
  3. Add the SpecFlow "SpecFlow.Tools.MsBuild.Generation" NuGet package
  4. Add the "SpecFlow.NUnit" NuGet package
  5. Add a SpecFlow Feature to the solution
  6. Generate feature step definitions
  7. Build the solution
  8. Run SpecFlow tests

All 14 comments

Can you clarify in the original report if you're using the SpecFlow.Tools.MsBuild.Generation NuGet package, or SpecFlowSingleFileGenerator custom tool?

Hi,
I am new to specflow. So can you please tell me where I can check this settings? I will mention it here.
Thank you in advance!

I meant in the description above for this issue that you've raised - there's a bunch of questions/fields that you can select to provide more information about the way you're using SpecFlow. By filling in those, it will be easier for someone to help you.

.NET Framework = 4.5
feature.cs files are generated using = SpecFlowSingleFileGenerator custom tool
Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings= Enabled

Hi @hemant2007,

the SpecFlowSingleFileGenerator custom tool does not work anymore when using SpecFlow 3 or above. Please use the SpecFlow.Tools.MsBuild.Generation NuGet package. You can read more about this topic here: https://specflow.org/documentation/Generate-Tests-from-MsBuild/.

Additionally, to configure a unit test provider (NUnit, xUnit, MsTest or SpecFlow+ Runner), you must reference the adjacent package; in your case SpecFlow.NUnit. For more information I'd refer you to our documentation: https://specflow.org/documentation/NuGet-Packages/.

Hope this helps. Please report back whether this fixes your issue.

Hi david,
Thanks for reply.
I have removed SpecFlowSingleFileGenerator from properties menu of .feature file. And added SpecFlow.Tools.MsBuild.Generation NuGet package to VS2015.
I am able to compile code
However I can't see feature.cs file and RunTests option ?
.cs file is Not getting generated.

Can anyone look into this ?

@hemant2007 What version are you really using? You have checked 3.0, but in the text you mention 1.9 and 2.1.
You have NUnit 2.2 which is really really old, but using sdk- style projects (which are new).

You gave us too much information that is contradicting. Please clarify what you are really using.

If it is really 1.9 and 2.1, we dropped support for everything prior 2.3.2 in the VS Extension. See https://specflow.org/2018/vs-integration-breaking-changes-affects-all-users/

I am having what appears to be the same issue and I am just trying to get a brand new project going with a default SpecFlow Feature and all the latest versions of everything - I am not doing anything with an existing SpecFlow project here. I am on VS2019 and I took an update to the IDE yesterday or this morning. I am creating a new C# class library (.NET Framework) project, installing the latest SpecFlow NuGet package (3.0.224), and then creating a new SpecFlow Feature.

As soon as I create the Feature, the solution will no longer build. I uninstalled the SpecFlow Extension and re-installed (the latest). I have tried to get this going about a dozen times this morning (with new solutions each time) and with no combination of SpecFlow NuGets and whatever Extension version I had before or now will result in a solution that will build after a SpecFlow Feature is added.

I read something further up about "SpecFlow.Tools.MsBuild.Generation" so I installed that (which also brought a "SpecFlow" NuGet with it), and then I ended up with the below errors.

I'm going to reboot, but unless I update this comment or reply that the reboot helped, please assume that I'm still dead in the water.

What should be the series of steps and with what NuGet(s) and what Extension(s) in order to get going from zero to having a simple SpecFlow project with the default sample test Feature that will also result in a solution that will build (and will _still_ build after Feature Steps have been generated)?

Please let me know if I missed something in the docs or if you need more info. I was fairly experienced with SpecFlow from around late 2016 to the beginning of 2018, so I have been out of things for a while.

edit: same results after the reboot, I again started with a brand new Solution, added SpecFlow latest version NuGet, then it barked about MsBuild Generation again, so I installed that NuGet, and arrived at the same errors as the previous screen shot. I don't at this point know a way to create a new Solution with a SpecFlow Feature...

image

Hi,
At last I installed older version of specflow from https://github.com/techtalk/SpecFlow.VisualStudio/releases this link. Now I am able to generate code as soon as I save feature file, without changing any project settings. I don't know why I was unable to generate code on latest specflow. May something is missing,may be this is not documented yet. Somehow I am not confident on latest specflow version. Please update step by step procedure to migrate if any.

@hemant2007 The upgrade info is here.

@Userjland00 Things have changed with SpecFlow 3, so I'd suggest you read the link above. The recommended setup is to use the MSBuild generation, which requires the package you installed. However, it's not compatible with the old method of generating code behind files - it's either/or, hence the message you are getting. See the MSBuild documentation here for info on how to remove the custom tool from your feature files.

There's also a related option in the Settings in VS - hence the "Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings" section in the issue template. You can disable this by opening the settings in VS (Tools | Options | SpecFlow).

Thanks Stephen-Mc, I was able to get past the build errors after following your suggestions and also after reading the documentation. I had previously thought the documentation would only apply when opening older projects with existing SpecFlow tests (I was thinking that when starting with a new project everything would just work).

Below the is the process I followed to get going. This issue is now resolved for me, thanks again!

  1. Change the "_Enable SpecFlowSingleFileGenerator Custom Tool_" setting in VS Options to 'False'
  2. Create a new C# Class Library solution using .NET Framework
  3. Add the SpecFlow "SpecFlow.Tools.MsBuild.Generation" NuGet package
  4. Add the "SpecFlow.NUnit" NuGet package
  5. Add a SpecFlow Feature to the solution
  6. Generate feature step definitions
  7. Build the solution
  8. Run SpecFlow tests

Issue is resolved => closing

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings