Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpecFlow project load failed

I have a project with tests based on SpecFlow. Sometimes there is an issue that a working source code (works on other computers and build server) fails to load in Visual Studio 2015 with an info load failed in Solution Explorer and following error message on Output console:

C:\Project\Tests.csproj : error : The imported project "C:\Project\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\Project\Tests.csproj

Project uses:

  • SpecFlow for Visual Studio 2015 (VS extension)
  • SpecFlow (nuget package)
like image 536
andrew.fox Avatar asked Dec 07 '25 19:12

andrew.fox


1 Answers

It turned out to be an issue with project file (csproj). It was manually extended with TechTalk.SpecFlow.targets like follows:

<Import Project="..\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets" />

But when directories were cleaned (e.g. by git reset hard), there were no packages, so project could not be loaded to perform the nuget restore.

The solution was to extend Import with a condition Exists.

<Import Project="..\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets" 
    Condition="Exists('..\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets')" />
like image 74
andrew.fox Avatar answered Dec 09 '25 16:12

andrew.fox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!