首页 文章

无法在Visual Studio 2017上选择Cordova Global

提问于
浏览
3

我在visual studio 2017上有一个cordova应用程序.VS2017使用Cordova 6.3.1但是我需要使用Cordova版本7.1.0 .

所以我必须按照此链接中的指定全局安装cordova https://evothings.com/doc/build/cordova-install-windows.html

然后我从我的项目中打开config.xml并转到更改工具集名称,但它显示“Global Cordova Version(当前未安装)”

有任何帮助来解决这个问题吗?

1 回答

  • 1

    如果您已经安装了Node.js,则可以通过在命令行界面窗口( cmd.exe )中键入它来安装 Cordova 7.1.0

    npm install -g cordova@7.1.0

    现在,因为 changing the CLI version is not as reliable as we would want ,我建议按照以下步骤在Visual Studio 2017中创建新的应用程序:

    转到 File > New > Project > Blank App (Apache Cordova)

    在View Code模式下打开 config.xml 并找到:

    <vs:toolsetVersion>6.3.1</vs:toolsetVersion>
    <engine name="android" spec="5.2.1" />
    

    用 . . . 来代替:

    <vs:toolsetVersion>7.1.0</vs:toolsetVersion>
    <engine name="android" spec="6.3.0" />
    

    7.1.0 是您全球安装的Cordova版本 .

    选择 Device 作为目标 .

    现在 Build > Build Solution

    保存,关闭并重新加载项目 . 在设计器模式下访问 config.xml 时,您将看到 Global Cordova 7.1.0 作为选定的工具集 .

    enter image description here

    为了构建,您可能需要使用外部Android SDK构建工具( API 26 )而不是Visual Studio(API 25)提供的工具 .

    enter image description here

    使用Android SDK Manager来管理版本,不需要为此获得Android Studio .

    enter image description here

    在现有项目上更改CLI时,请记住遵循the guidelines from Microsoft . 但是我强烈建议 creating a new one and then importing your files and adding your plugins 以避免潜在的问题 .

相关问题