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:
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')" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With