1
votes

When generating feature.cs files with either the Visual Studio "Regenerate Feature Files" option or "Run Custom Tool" on the file itself, a file with a "1" is generated, but only for some files.

I'd like to know what makes these files special.

Generated with VS

Then if I generate files with the Specflow generateall command prompt, the same files that generated with a "1" are generated next to the feature file, not "under" it. These tests cannot be found in Test Explorer. As you can see in the image below, some tests generate OK.

Generated with the command prompt

Please note I deleted all feature.cs files between generation. It is not adding the 1 because a .feature.cs file already exists.

2

2 Answers

1
votes

Sometimes Visual Studio doesn't write in the expected file and adds a 1 to the name. Most of the time we get issues about it, it is a lock on a existing file. Sometimes it was a bad state in Visual Studio and a simple restart fixed it.

In the custom tool we never specify the file name of the result. We only specify the ending. Code for that is here: https://github.com/techtalk/SpecFlow.VisualStudio/tree/master/VsIntegration/SingleFileGenerator

0
votes

I thought I would post my solution on how I removed the "1" from the generated filename, in case somebody come here looking (as I did).

  • Delete the feature.cs file
  • Open the .csproj for your SpecFlow project in a editor
  • Find the name containing the "1" and remove the "1"
  • Save the .csproj file, reload project in VS and build solution
  • Right click on your feature file and Run Custom Tool
  • Your feature.cs file should now be generated without a 1 in the name

This worked for me.