我在为Windows构建新的cordova项目时遇到了问题。
我已经安装了以下版本:
- cordova@7.0.0,但使用cordova@6.5也可以重现此问题
- Visual Studio 2017企业版,其中包括Apache Cordova工具、Windows Mobile模拟器等。
- 已安装MS Build Tools v14和v15。
因此,要重现此问题,请执行以下操作:
cordova create project1
cd project1
cordova platform add windows
cordova build windows
然后会出现以下错误:error MSB4019: The imported project "C:\Program Files (86)\MSBuild\Microsoft\VisualStudio\v14.0\JavaScript\Micros oft.VisualStudio.WJProject.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk
如果将--verbose标志添加到构建中,则会注意到C:\WINDOWS\system32\reg.exe query,HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\15.0,/v,MSBuildToolsPath
命令未返回成功,因此使用的是Build Tools v14而不是v15。
如果使用Visual Studio 2017创建新项目,则可以在Visual Studio中成功编译和运行,但在cordova build windows
命令中也会出现相同的错误。
我认为如果正确安装了注册表密钥,则可以正常工作。如何正确添加这些密钥?或者Visual Studio正在做什么,而在cordova或taco命令中没有被执行?