Cordova在Windows 10和VisualStudio 2017上构建Windows [英] Cordova build windows on Windows 10 and VisualStudio 2017
问题描述
尝试在Windows 10上构建Cordova应用程序总是会失败,
(node:31) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): No valid MSBuild was detected for the selected target.
在Windows 10 Pro 1709和VisualStudio 2017 Community Edition上运行.
Trying to build the Cordova App on Windows 10 always fails with
(node:31) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): No valid MSBuild was detected for the selected target.
on Windows 10 Pro 1709 with VisualStudio 2017 Community Edition.
我完全按照我已经安装了带有Mobile Development with Javascript
软件包的VS,其中包含了cordova工具.我还安装了其他用于Visual Studio 2017的构建工具.
为了创建测试应用,我使用了来自文档的命令:
I have installed VS with package Mobile Development with Javascript
which includes the cordova tools. I also installed the additional Build Tools for Visual Studio 2017.
To create the test app, I used the commands from the docs:
cordova create test
cd test
cordova platform add windows
cordova build windows
经过数小时的研究,我发现问题可能是活动的WindowsPolicy DisableRegistryTools
,但这不是造成此问题的原因.重新安装VisualStudio也没有任何效果.错误消息始终是相同的.
After hours of research, I found out the issue could be an active WindowsPolicy DisableRegistryTools
, but this is not causing the issue. Reinstalling VisualStudio does also not have any effect. The error message is always the same.
我刚刚检查了cordova requirements
,我之前不知道该命令.这是输出:
I just checked cordova requirements
, I did not know that command before. This is the output:
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的旧版本.但是下载不再可用.
If it is possible, I would try the required older version of VisualStudio. But the download is not available anymore.
推荐答案
我终于按照
安装 VistualStudio Community 2017 或更高版本
带有选项: 通用Windows平台开发, Universal Windows Platform development, 使用JavaScript进行移动开发 Mobile development with JavaScript 安装用于Visual Studio 2017的构建工具,您可以在其他工具和框架部分 带有选项: Visual C ++ Buildtools Visual C++ Buildtools 用于Web开发的构建工具 Buildtools for web development .NET Core-Buildtools .NET Core-Buildtools Node.js Buildtools Node.js Buildtools 我还将这些首选项添加到config.xml I also added these preferences to the config.xml
如果使用的是 Ionic 3 ,则可以使用 bash 运行
If you are using Ionic 3, you can use bash to run 如果应用程序样式仍然类似于Android,请将此配置添加到 If the App style remains Android-like, add this config to
+添加可选:Windows 10移动仿真器(秋季创作者更新)
+添加可选:Windows 10 SDK(10.0.15063.0)和UWP:C#,VB,JS
+添加可选:Windows 10 SDK(10.0.10586.0)
+add optional: Windows 10 Mobile-Emulator (Fall Creators Update)
+add optional: Windows 10 SDK (10.0.15063.0) für UWP: C#, VB, JS
+add optional: Windows 10 SDK (10.0.10586.0)
+添加可选:Windows 10移动仿真器(秋季创作者更新)
+添加光学:UWP-科尔多瓦工具
+add optional: Windows 10 Mobile-Emulator (Fall Creators Update)
+add optinoal: UWP-Tools for Cordova
+添加可选:Windows 10 SDK(10.0.16299.0)for Desktop C ++
+添加可选:CMake的Visual C ++工具
+add optional: Windows 10 SDK (10.0.16299.0) für Desktop C++
+add optional: Visual C++-Tools für CMake
+添加可选:.NET Framework 4–4.6的开发工具
+添加可选:.NET Core 2.0-开发工具
+添加可选:NuGet-Ziele和Buildaufgaben
+添加可选:TypeScript 2.6 SDK
+添加可选:扩展的ASP.NET功能
+add optional: Development tools für .NET Framework 4–4.6
+add optional: .NET Core 2.0-Development tools
+add optional: NuGet-Ziele und Buildaufgaben
+add optional: TypeScript 2.6 SDK
+add optional: Extended ASP.NET-Features
cordova platform add windows@6.0.0
否则5.0.0将被添加到您的项目中,这与VisualStudio 2017大多不兼容.MSBUILDDIR
设置为C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
cordova platform add windows@6.0.0
otherwise 5.0.0 will be added to your project, which is mostly incompatible to VisualStudio 2017.MSBUILDDIR
to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
<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>
-如果仍然遇到错误,请尝试在Visual Studio中打开项目并在那里构建.
npm install
,ionic cordova platform add windows@6.0.0
和ionic cordova build windows --prod
进行编译并复制到平台/万维网.但是必须使用cordova build windows
或cordova run windows
- If you still run into errors, try opening the project in Visual Studio and build there.
npm install
, ionic cordova platform add windows@6.0.0
and ionic cordova build windows --prod
to compile and copy to platform/www. But building the .appx package must be done with CMD using cordova build windows
or cordova run windows
app.module.ts
app.module.ts
imports: [
IonicModule.forRoot(MyApp, {
mode: 'wp',
})
],
这篇关于Cordova在Windows 10和VisualStudio 2017上构建Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!