问题
Fairly simple one: I'm trying to make SpecFlow generate feature.cs files, but in a directory I specify and not the default (which is the same directory as the associated feature file). Is this possible?
回答1:
Not by default, but it might be possible.
SpecFlow uses an inbuilt mechanism inside Visual Studio called a custom tool. its a means of automatically performing an action whenever a file changes and is also used in designers (such as the winforms, asp.net etc) which also generate an xxx.designer.cs file. For more details see https://msdn.microsoft.com/en-us/library/hefydhhy.aspx
This is controlled by a couple of entries in the .csproj file
<None Include="xxx.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>xxx.feature.cs</LastGenOutput>
</None>
and
<Compile Include="xxx.feature.cs">
<DependentUpon>xxx.feature</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
So as you can see you have all the information you need here to change the file locations and keep the association between them. However I've never tried it, so let us know how you get on.
来源:https://stackoverflow.com/questions/28691852/generating-specflows-feature-cs-files-in-a-different-location-to-the-feature-fi