SpecFlow
SpecFlow copied to clipboard
Moving/coping feature files adds uncessary entries to the csproj in VS2019 and Rider
SpecFlow Version
3.7.38
Which test runner are you using?
xUnit
Test Runner Version Number
2.4.1
.NET Implementation
.NET Core 3.1
Project Format of the SpecFlow project
Sdk-style project format
.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation NuGet package
Test Execution Method
Visual Studio Test Explorer
SpecFlow Section in app.config or content of specflow.json
No response
Issue Description
Moving and copying feature files in the IDEs adds extra unnecessary SpecFlowFeatureFiles
entries to the csprojs, which could lead to compilation warnings.
The error is independent from the project target framework and the unit test provider used.
Steps to Reproduce
Rider 2021.1
Create a new SpecFlow project
-
Copy the Calculator.feature to the same folder 'Features'
The following extra entry is added to the csproj:
<ItemGroup> <SpecFlowFeatureFiles Update="Features\Calculator - Copy.feature"> <CodeBehindFile>Features\Calculator.feature.cs</CodeBehindFile> </SpecFlowFeatureFiles>
-
Move the Calculator.feature to the Steps folder
The following extra entry is added and warning is generated because of the missing path
<ItemGroup> <SpecFlowFeatureFiles Update="Steps\Calculator.feature"> <CodeBehindFile>Features\Calculator.feature.cs</CodeBehindFile> </SpecFlowFeatureFiles>
Features\Calculator.feature.cs : warning : For codebehind file 'Features\Calculator.feature.cs', no feature file was found.
Visual Studio 2019 Version 16.8.3
Create a new SpecFlow project
-
Copy the Calculator.feature to the same folder 'Features'
The following extra entry is added to the csproj:
<ItemGroup> <SpecFlowFeatureFiles Update="Features\Calculator - Copy.feature"> <Visible>$(UsingMicrosoftNETSdk)</Visible> <CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile> </SpecFlowFeatureFiles>
Link to Repro Project
No response
The IDEs are changing the csprojs file. We don't have any code that makes these changes.
I know that this is not intentionally done by SpecFlow, however it is the SpecFlow msbuild props (even keeping the placeholders) which are copied as it is (in the case of VS2019) to the project file
https://github.com/SpecFlowOSS/SpecFlow/blob/f9561e19f5fb391b6fec07cc6d6dcdc8d48f9278/SpecFlow.Tools.MsBuild.Generation/build/SpecFlow.Tools.MsBuild.Generation.props#L47-L50