我有一个基于SpecFlow的测试项目。有时会出现一个问题,即工作源代码(适用于其他计算机和构建服务器)无法在Visual Studio 2015中加载解决方案资源管理器中的信息load failed
,并在输出控制台上显示以下错误消息:
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
项目用途:
答案 0 :(得分:4)
原来是项目文件(csproj)存在问题。它使用TechTalk.SpecFlow.targets
手动扩展,如下所示:
<Import Project="..\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets" />
但是当清理目录时(例如通过git reset hard),没有包,因此无法加载项目来执行nuget恢复。
解决方案是使用条件Import
扩展Exists
。
<Import Project="..\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets"
Condition="Exists('..\packages\SpecFlow.2.1.0\tools\TechTalk.SpecFlow.targets')" />