xeraphim
xeraphim

Reputation: 4645

Specflow generation failed - Could not load file Microsoft.Build.Framework

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.

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

Upvotes: 1

Views: 1276

Answers (2)

xeraphim
xeraphim

Reputation: 4645

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...

Upvotes: 0

Andreas Willich
Andreas Willich

Reputation: 5825

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.

Upvotes: 1

Related Questions