feature.cs and tests are not generated using SpecFlow.Tools.MsBuild.Generation 3.0.213
Version number: 3.11
packages.config<PackageReference> tagsSpecFlow.Tools.MsBuild.Generation NuGet packageSpecFlowSingleFileGenerator custom toolEnable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings<assemblyIdentity name="TechTalk.SpecFlow" publicKeyToken="07781....." culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
I am not seeing test hierarchy in test explorer and also I am not seeing feature.cs file generated. My setup is
Microsoft.NET.Test.Sdk
Specflow 3.0.213
SpecFlow.Tools.MsBuild.Generation 3.0.213
SpecFlow.NUnit 3.0.213
NUnit3 Test Adapter
NUnit 3.11
Upon building and rebuilding , I get this in VS2019 output tab
Running all tests in C:\...\bin\debug\something.dll
NUnit failed to load C:\...\bin\debug\something.dll
NUnit Adapter 3.13.0.0: Test execution complete
No test is available in C:\....\bin\debug\something.dll Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
There is no error in error tab.
I do not see feature.cs in solution explorer and neither do I see tests in test explorer
Once above described setup is done , build the project
Could you create a small example project where we can reproduce the issue?
I'll be honest and say , I will try to create , if I get chance. I am unable to promise something. But meanwhile I can provide you information as much as you require.
Does anyone has any idea about this issue, I am still having it. I matched the framework that SpecFlow.Tools.MsBuild.Generation was built against with my targeted framework but that didn't help either.
I hope you find a solution soon. This is severely affecting our development work as well as our trust and reliance on SpecFlow as a tool for acceptance and integration testing.
In one of the projects in which I need to add feature files, when I try to add one using the "SpecFlow Feature File" template, I always get a build error Source file (...)\Feature1.feature.cs could not be found.
No code behind file is generated on save, nor is it generated on build.
I've reverted to the previous version of the extension as suggested in https://github.com/techtalk/SpecFlow/issues/1557#issuecomment-490827846 and, ate least, managed that existing feature files could be changed (which wasn't happening as well).
I've tried all suggestions, including:
.csproj file;<PackageReference Include="SpecFlow" Version="3.0.213" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.0.213" />
The struggle my teammates and I have been having is costing the team too many unproductive development hours (and days, actually) with what should be a seamless procedure: add new scenarios and new features to existing projects.
@antoniomapinho If you provide a project to reproduce the issue, we will have a look at it. There are so many different possibilities how the project could be setup, we often can't reproduce your issues only with a description of steps.
@mygithub07 I updated our MSBuild example to the latest version of SpecFlow. It is here: https://github.com/techtalk/SpecFlow-Examples/tree/master/MSBuild/OldCSProj_SpecFlow30 I would suggest that you compare your project with this one. This is working. So there have to be a difference between your project and this.
@SabotageAndi I understand your point of there being a number of possibilities, but I find it hard to accept that the mere fact of an auto updating extension preventing us from simply adding a new scenario to a feature (or simply deleting a character and reentering it) and causing the project not to compile. Then, updating the package requiring so, so many changes and causing yet more different errors in each step.
I'm currently using SpecFlow for Visual Studio 2019 v2019.0.18.18989 with the following options:

The current behavior is:
.cs files;I'm enclosing the .csproj file contents, stripped from sensitive information, hoping it's helpful.
Service.Host.Tests.Acceptance.zip
@SabotageAndi , Thank you for sharing that. I compared the project you mentioned and added <None Include="Google.feature.cs"/> to .csproj , I can see feature.cs in solution explorer now but I cant see tests in test explorer. I am using nunit and the project you mentioned is using MSTest. Can that be the reason? When built, I see in output tab NUnit failed to load C:\
@antoniomapinho
You have SpecFlowSingleFileGenerator set at your feature files. It's at the end of the csproj. This doesn't work with SpecFlow 3. You have to remove it.
Hi @SabotageAndi, thanks for your reply. Despite them being in the example csproj, I had already tried removing those, both from the file properties and directly in the csproj, with the same outcome.
@SabotageAndi - Thank you . I can run it now. I used MStest as yours and not NUnit , which I as using earlier
@antoniomapinho After removing them, what did you do to get an error?
Hi @SabotageAndi,
So, with the attached.csproj (removed all SpecFlow <ItemGroup>) it compiles correctly. However:
.feature file, it builds without errors but .cs files are not regenerated (changes are not applied);.feature file (Add -> New Item -> Specflow Feature File) generates a .cs file immediately, as well as the following in .csproj:<ItemGroup>
<Compile Update="Features\Feature1.feature.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Feature1.feature</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<SpecFlowFeatureFiles Update="Features\Feature1.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Feature1.feature.cs</LastGenOutput>
</SpecFlowFeatureFiles>
</ItemGroup>
Removing these <ItemGroup> entries and building, causes the following:

Service.Host.Tests.Acceptance.zip
I managed to move forward, by moving back with these steps:
.feature and copy the content for each one;@SabotageAndi I've prepared a sample project in which all these issues are happening. Please check it out.
Service.Host.Tests.Acceptance3.zip
@SabotageAndi after some experiments, I've realized this probably has to do with my particular development environment, but I have yet to figure out the underlying issue. Any idea?
An update on this: I managed to get it working by uninstalling both VS 2017 and 2019 and installing VS 2019 only. Not sure why, but it's working now.
@antoniomapinho good to hear! Sorry for not answering. We had a public holiday in Austria and it was a little bit stressful in the last days
Select Tools | Options from the menu in Visual Studio.
Browse to SpecFlow | General in the list on the left (you can use the search field to restrict the options).
Set Enable SpecFlowSingleFileGenerator CustomTool to true under Legacy.

@gshokar .. You are my life saver. Now my TestExplorer is updating if change any tag for the scenario.
@gshokar You are great. What I understand here is, people who started working with specflow versions less than 3 and used SpecFlowSingleFileGenerator as their custom tool have started getting this problem when they upgraded their SpecFlow version to 3.
SpecFlow 3 doesn't support SpecFlowSingleFileGenerator and considers it as a legacy feature.
If we want to continue using SpecFlowSingleFileGenerator as custom tool, enable it as shown by @gshokar
I too had the issue related to feature file generation. I removed the SpecFlowSingleFileGenerator from all my feature files and i moved the specflow configurations from app.config to specflow.json file. Now feature files are getting generated. Thanks guys :+1:
install these NPM-
1) SpecFlow-3.0.220
2) SpecFlow.MsTest - 3.0.220
3) SpecFlow.Tools.MsBuild.Generation-3.0.220
will generate .cs file and it will resolve the issue
Select Tools | Options from the menu in Visual Studio.
Browse to SpecFlow | General in the list on the left (you can use the search field to restrict the options).
Set Enable SpecFlowSingleFileGenerator CustomTool to true under Legacy.
After setting the above option, if you still do not see the .cs file. It might probably be generated but not included in the project. Try selecting "show all files" in solution explorer and find and include generated file in project.
Select Tools | Options from the menu in Visual Studio.
Browse to SpecFlow | General in the list on the left (you can use the search field to restrict the options).
Set Enable SpecFlowSingleFileGenerator CustomTool to true under Legacy.
Thanks very much @gshokar!!!! 😇
Most helpful comment
Select Tools | Options from the menu in Visual Studio.

Browse to SpecFlow | General in the list on the left (you can use the search field to restrict the options).
Set Enable SpecFlowSingleFileGenerator CustomTool to true under Legacy.