编辑功能文件时,SpecFlow .feature.cs 文件会重复
SpecFlow .feature.cs file gets duplicated when feature file is edited
当我编辑 Foo.feature
时,SpecFlow 会创建一个新的 Foo1.feature.cs
而不是覆盖 Foo.feature.cs
。复制的文件然后由于重复的符号而导致编译错误。
它只发生在我项目中的一个 .feature 文件上——所有其他文件都正常运行。所有 .feature 和 .feature.cs 文件都在源代码管理下并添加到 Foo.csproj
文件中。
我想我发现了问题 - 在我的 .csproj 文件中我有这个条目:
<None Include="Foo.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Foo1.feature.cs</LastGenOutput>
</None>
我认为 <LastGenOutput>
混淆了 SpecFlow。我不知道它来自哪里,但将其更改为 <LastGenOutput>Foo.feature.cs</LastGenOutput>
解决了问题。
编辑: 我刚刚发现缺少 <LastGenOutput>
标记也会导致创建重复的 Foo1.feature.cs
文件。因此,如果缺少标签,请创建它并将正确的文件名放入其中。
在谷歌搜索 SpecFlow 和 "LastGenOutput" 后,我找到了这个帖子 - https://groups.google.com/forum/#!topic/specflow/SpOihmvoAOQ。它概述了相同的问题和解决方案:
Issue may be very annoying. Possible solution (do at you own risk!)
- delete all YourFeature1.feature.cs files in Visual Studio. Save project.
- close Visual Studio, open your .csproj file with notepad
- find the lines similar to this one:
YourFeature1.feature.cs
change them to
YourFeature.feature.cs
save, load project in Visual Studio. Enjoy.
但是您必须已经知道解决方案才能找到该线程。
当我编辑 Foo.feature
时,SpecFlow 会创建一个新的 Foo1.feature.cs
而不是覆盖 Foo.feature.cs
。复制的文件然后由于重复的符号而导致编译错误。
它只发生在我项目中的一个 .feature 文件上——所有其他文件都正常运行。所有 .feature 和 .feature.cs 文件都在源代码管理下并添加到 Foo.csproj
文件中。
我想我发现了问题 - 在我的 .csproj 文件中我有这个条目:
<None Include="Foo.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Foo1.feature.cs</LastGenOutput>
</None>
我认为 <LastGenOutput>
混淆了 SpecFlow。我不知道它来自哪里,但将其更改为 <LastGenOutput>Foo.feature.cs</LastGenOutput>
解决了问题。
编辑: 我刚刚发现缺少 <LastGenOutput>
标记也会导致创建重复的 Foo1.feature.cs
文件。因此,如果缺少标签,请创建它并将正确的文件名放入其中。
在谷歌搜索 SpecFlow 和 "LastGenOutput" 后,我找到了这个帖子 - https://groups.google.com/forum/#!topic/specflow/SpOihmvoAOQ。它概述了相同的问题和解决方案:
Issue may be very annoying. Possible solution (do at you own risk!)
- delete all YourFeature1.feature.cs files in Visual Studio. Save project.
- close Visual Studio, open your .csproj file with notepad
- find the lines similar to this one:
YourFeature1.feature.cs
change them to
YourFeature.feature.cs
save, load project in Visual Studio. Enjoy.
但是您必须已经知道解决方案才能找到该线程。