1

When I add a new SpecFlow-feature file to our solution, I get the following error:

Generation error: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Das System kann die angegebene Datei nicht finden.

This has never happened before, last friday it worked without any problem.

  • What could be causing this error to happen and how can I fix it?

I've tried to remove the reference to Microsoft.Build.Framework and readd it but it didn't have any effect...

Thanks in advance

Edit: I've made sure that the assembly is reference with the correct version but the error is still there...

enter image description here

xeraphim
  • 4,375
  • 9
  • 54
  • 102

2 Answers2

1

This is a known issue (https://github.com/techtalk/SpecFlow/issues/857) for what we don't have a fix yet.

Sometimes deinstalling and reinstalling the Visual Studio extension helps.

The best workaround is to not generate the code-behind files when you save the feature file, but to generate them when you compile your project.
Have a look at the documentation for that: http://specflow.org/documentation/Generate-Tests-from-MsBuild/
You simply have to import one target file in your csproj and remove the CustomTools from the feature files in the project explorer.

Andreas Willich
  • 5,665
  • 3
  • 15
  • 22
  • Hi, @Andreas. I think I found the root cause of the issue and I wrote in the github thread. See this answer at https://stackoverflow.com/a/44723132/492336, it worked from me. Maybe SpecFlow was changing the current directory in Visual Studio's process context. – sashoalm Feb 16 '18 at 16:27
0

I fixed the problem with the following steps:

  • Add <Import Project="..\packages\SpecFlow.2.2.1\tools\TechTalk.SpecFlow.targets" Condition="Exists('..\packages\SpecFlow.2.2.1\tools\TechTalk.SpecFlow.targets')" /> at the end of the project file
  • Remove SpecFlowSingleFileGenerator from the feature files
  • Save & Build
  • Readd SpecFlowSingleFileGenerator to the feature files
  • Save & Build

this helped me this time...

xeraphim
  • 4,375
  • 9
  • 54
  • 102
  • why are you downvoting this? This is what I did to fix it. If you don't like it, at least leave a comment why you don't like it. – xeraphim Nov 21 '17 at 14:33