
准备工作:
1、ionic3环境下新建的ionic1项目:
ionic start test323 tabs --type=ionic1
2、安装visual studio;

cordova官方安装步骤:https://cordova.apache.org/docs/en/6.x/guide/platforms/win8/index.html
visual studio installer:https://www.visualstudio.com/zh-hans/downloads/?rr=https%3A%2F%2Fforum.ionicframework.com%2Ft%2Fbuilding-windows-10-app%2F92416%2F9

sdk等工具:




好了,现在开始:
注意:以下几个错误可能需要重新添加平台。
进入项目目录,添加windows平台:
ionic cordova platform add windows
ionic cordova run windows
可能会报几个错误:
1、
[ERROR] An error occurred while running cordova build windows (exit code 1):
MSBuild v4.0 is not supported, aborting.
Error: AppPackages doesn’t exists.
添加环境变量:
VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
config.xml中添加:
<preference name=“windows-target-version” value=“10.0”/>
<preference name=“windows-phone-target-version” value=“10.0” />
可能需要重新添加平台。
具体参见:https://forum.ionicframework.com/t/building-windows-10-app/92416/9
2、“C:/ionic/test323/platforms/windows/www/lib/ionic/scss/tsconfig.json”中的 "files" 列表为空。
*临时解决办法:
在C:\ionic\test323\www\lib\ionic\scss
目录下找到tsconfig.json
,在同级目录下添加一个‘1.ts’,打开tsconfig.json
改为:
{
"version": "1.5.0-alpha",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"filesGlob": [
"./**/*.ts",
"!./node_modules/**/*.ts"
],
"files": ["1.ts"]
}
有意可查看该链接,考虑具体解决办法:
https://github.com/TypeStrong/ts-loader/issues/405
3、
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.Uap.targets(79,5): error MSB3073: ���"*Undefined*\CommonExtensions\Microsoft\TypeScript\WinRt2ts.exe" @"build\windows\bld\winrtrefs\winrt2ts.rsp"�����˳�������Ϊ 3�� [C:\ionic\test323\platforms\windows\CordovaApp.Windows10.jsproj] Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe: Command failed with exit code 1
项目建好了,ionic cordova run windows
没问题,然后使用visual studio调试:

然后再次要执行
ionic cordova run windows
时,就报上面的错误。原因不明,重新添加平台后
ionic cordova run windows
不报错。投机解决办法,保留第一次添加平台执行
ionic cordova run windows
后,目录app\platforms\windows
下CordovaApp.Windows10.jsproj
文件,报错时,把这个文件替换了。
网友评论