DEV Community

Chris Otto
Chris Otto

Posted on • Originally published at chrisotto.dev on

1 1

Create Specflow `feature.cs` At Build Time

Change Feature File to Generate the ~.feature.cs at Compile Time

Whenever a new Specflow file is created in the solution it is automatically created with the SpecFlowSingleFileGenerator specification in the Custom Tool attribute. This file generator creates the background file on save instead of during the buildprocess, follow these steps to make the change:

Prerequisite

To make the change you will need to add an extension to your instance of Visual Studio if you don’t have it already.

  • In Visual Studio go to Extension Manage Extensions
  • Select Online and search for ‘File Nesting’
  • Install the ‘File Nesting’ extension and close Visual Studio, once closed the installation will begin
  • When prompted after VS closes, select ‘Modify’ from the pop-up window

Making the Change

With the ‘File Nesting’ extension installed we are now ready to change how the ~.feature.cs is created for our feature file.

  • Modify the existing properties
    • In the Solution Explorer, R-Click on the feature file Select Properties
    • The Properties window should pop up below the Solution Explorer
    • In the Custom Tool attribute, delete ‘SpecFlowSingleFileGenerator’ leaving the Custom Tool attribute blank
  • Creating the File dependency
    • With the Custom Tool removed, build the solution
    • Once built make sure that you have ‘Show All Files’ selected and you should see the ‘~.feature.cs’ file for your feature file in the Solution Explorer
    • If you don’t see it and you already had ‘Show All Files’ enabled, try refreshing the Solution Explorer and it should populate
    • R-Click on the ~.feature.cs file Select ‘File Nesting’
    • Nest the file under the respective feature file

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay