32
votes

I've got ~30 SpecFlow feature files, and I recently removed the Foo.feature.cs files from source control because I got sick of resolving merge conflicts in Designer Generated code.

I did not exclude or remove these files from my Visual Studio project, so Visual Studio still thinks they should be there, they are just missing on the hard disk.

Ideally I'd like to just click on a root folder and regenerate all the code behind files, but no such option exists for VS 2010 and SpecFlow 1.9. I'd even be OK with programmatically regenerating them from the command line, creating another custom tool or adding a pre-compile build event.

Is there a way to regenerate all of the the Designer generated code behind files for SpecFlow features (*.feature.cs files) without right-clicking on each .feature file and clicking "Run Custom Tool"?

2
Well you can also just perform a save on the .Feature file as that automatically performs the "Run Custom Tool". Otherwise its going to be a case of simulating the call to RunCustomTool - AlSki
I was hoping it didn't involve any sort of operation on each file individually. - Greg Burghardt
you can't right click on the project and choose 'Regenerate feature files'? Is that option not available in vs2010? - Sam Holder
@SamHolder Oh, good lord. It's right there in front of my face. If you post that as an answer, I'll mark it. Thanks! - Greg Burghardt
No problem. Answered now. Didn't want to before in case I got the 'not in my version of visual studio' down votes :) - Sam Holder

2 Answers

65
votes

You can right click on the project and choose 'regenerate feature files' to do them all at once.

9
votes

It runs much quicker from the command prompt. Go to your Specflow package tools folder and run the following command line. It also ensures the correct Specflow version is added to the files.

specflow.exe generateall <My_Testing.csproj>