Search code examples
c#.netspecflowacceptance-testing

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.

  • 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


Solution

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