![](/img/trans.png)
[英]cordova build android in windows 10 shows the following issue
[英]Cordova build windows on Windows 10 and VisualStudio 2017
嘗試在Windows 10上構建Cordova App總是失敗
(node:31) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): No valid MSBuild was detected for the selected target.
在Windows 10 Pro 1709和VisualStudio 2017社區版上。
我完全按照Windows的cordova文檔中有關 Windows 10的所有說明進行操作
我已經使用Mobile Development with Javascript
Cordova工具的Mobile Development with Javascript
包安裝了VS。 我還為Visual Studio 2017安裝了其他構建工具 。
要創建測試應用,我使用了來自文檔的命令:
cordova create test
cd test
cordova platform add windows
cordova build windows
經過數小時的研究,我發現問題可能是活動的WindowsPolicy DisableRegistryTools
,但這不是造成此問題的原因。 重新安裝VisualStudio也沒有任何效果。 錯誤消息始終是相同的。
編輯:我只是檢查了cordova requirements
,我之前不知道該命令。 這是輸出:
Requirements check results for windows:
Windows OS: installed Windows 10
MSBuild Tools: not installed
MSBuild tools v.12.0 not found. Please install Visual Studio 2013 Express for Windows Update2 from https://www.visualstudio.com/downloads/download-visual- studio-vs
Visual Studio: not installed
Required version of Visual Studio not found. Please install Visual Studio 2013 Express for Windows Update2 from https://www.visualstudio.com/downloads/download-visual-studio-vs
Windows SDK: not installed
Windows SDK not found. Ensure that you have installed Windows 8.1 SDK along with Visual Studio or install Windows 8.1 SDK separately from https://dev.windows.com/en-us/downloads
Windows Phone SDK: not installed
Windows Phone SDK not found. Ensure that you have installed Windows Phone 8.1 SDK along with Visual Studio or install Windows Phone 8.1 SDK separately from https://dev.windows.com/develop/download-phone-sdk
Error: Some of requirements check failed
如果可能,我將嘗試所需的VisualStudio的較早版本。 但是下載不再可用。
通過遵循Cordova博客上最近發布的指南,我終於讓cordova build windows
並使cordova run windows
。
安裝VistualStudio Community 2017或更高版本
帶有選項 :
通用Windows平台開發,
+添加可選:Windows 10移動仿真器(秋季創作者更新)
+添加可選:Windows 10 SDK(10.0.15063.0)和UWP:C#,VB,JS
+添加可選:Windows 10 SDK(10.0.10586.0)
使用JavaScript進行移動開發
+添加可選:Windows 10移動仿真器(秋季創作者更新)
+添加光學:UWP-科爾多瓦工具
安裝適用於Visual Studio 2017的構建工具 ,您可以在其他工具和框架部分的VS下載頁面上找到它們
帶有選項 :
Visual C ++ Buildtools
+添加可選:Windows 10 SDK(10.0.16299.0)for Desktop C ++
+添加可選:CMake的Visual C ++-工具
Web開發的構建工具
+添加可選:.NET Framework 4–4.6的開發工具
+添加可選:.NET Core 2.0-開發工具
+添加可選:NuGet-Ziele和Buildaufgaben
+添加可選:TypeScript 2.6 SDK
+添加可選:擴展的ASP.NET功能
.NET Core-Buildtools
Node.js Buildtools
cordova platform add windows@6.0.0
MSBUILDDIR
設置為C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin
我還將這些首選項添加到config.xml中
<platform name="windows"> <preference name="windows-target-version" value="10.0" /> <preference name="windows-phone-target-version" value="10.0" /> <preference name="WindowsDefaultUriPrefix" value="ms-appx://" /> </platform>
如果使用的是Ionic 3 ,則可以使用bash運行npm install
, ionic cordova platform add windows@6.0.0
而ionic cordova build windows --prod
進行編譯並復制到platform / www。 但是,必須使用cordova build windows
或cordova run windows
使用CMD完成.appx軟件包的cordova build windows
如果應用程序樣式仍然類似於Android,請將此配置添加到app.module.ts
imports: [ IonicModule.forRoot(MyApp, { mode: 'wp', }) ],
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.