Windows platform build always trying to use Any CPU and getting error

I have an Ionic application where I have just added the Window platform on a Windows PC that has only Visual Studio 2017 installed.

After some other initial problems (eg this, and this ), I think I am up to the last hurdle, and that is I am getting the following error when trying to build (ie running ionic cordova build windows)…

Building project: H:\dev\apps\mobileapps\myapp\trunk\platforms\windows\CordovaApp.Windows10.jsproj
    Configuration : debug
    Platform      : anycpu
    Patching 10 in prebuild event...
    Injected base.js reference to the /www/index.html
    Removing /(
    *)(<script\s+(?:type="text\/javascript"\s+)?src="\/\/Microsoft.WinJS.2.0\/js\/base.js">\s*<\/script>)(\s*)/ from
    /www/index.html
    Removing /(
    *)(<script\s+(?:type="text\/javascript"\s+)?src="\/\/Microsoft.Phone.WinJS.2.1\/js\/base.js">\s*<\/script>)(\s*)/
    from /www/index.html
    Creating library
    H:\dev\apps\mobileapps\myapp\trunk\plugins\cordova-sqlite-storage\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\debug\SQLite3.UWP\SQLite3.UWP.lib
    and object
    H:\dev\apps\mobileapps\myapp\trunk\plugins\cordova-sqlite-storage\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\debug\SQLite3.UWP\SQLite3.UWP.exp
    SQLite3.UWP.vcxproj ->
    H:\dev\apps\mobileapps\myapp\trunk\plugins\cordova-sqlite-storage\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\debug\SQLite3.UWP\SQLite3.UWP.dll
    SQLite3.UWP.vcxproj ->
    H:\dev\apps\mobileapps\myapp\trunk\plugins\cordova-sqlite-storage\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\debug\SQLite3.UWP\SQLite3.UWP.pdb
    (Partial PDB)
    C:\Program Files (x86)\Microsoft Visual
    Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\Microsoft.Cpp.VCLibs120Universal.targets(103,5):
    warning MSB3842: Project "CordovaApp.Windows10" depends upon SDK "Microsoft Universal CRT Debug Runtime
    v10.0.15063.0" which supports apps targeting "UAP 10.0". To verify whether "Microsoft Universal CRT Debug
    Runtime v10.0.15063.0" is compatible with "UAP 10.0.15063.0", contact the SDK author or see
    http://go.microsoft.com/fwlink/?LinkID=309181.
    [H:\dev\apps\mobileapps\myapp\trunk\platforms\windows\CordovaApp.Windows10.jsproj]
    C:\Program Files (x86)\Microsoft Visual
    Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\Microsoft.Cpp.VCLibs120Universal.targets(103,5):
    error MSB3779: The processor architecture of the project being built "Any CPU" is not supported by the
    referenced SDK "Microsoft.UniversalCRT.Debug, Version=10.0.15063.0". Please consider changing the targeted
    processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to
    one of the architectures supported by the SDK: "x86, x64, ARM, ARM64".
    [H:\dev\apps\mobileapps\myapp\trunk\platforms\windows\CordovaApp.Windows10.jsproj]
    Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe: Command
    failed with exit code 1

Opening the solution in Visual Studio, the solution and project did originally have “Any CPU” set, but I have gone in and tried setting it to both x86 and ARM. I have saved all, and I can build the solution in Visual studio, but when I do the ionic build, it is always complaining about the “any cpu”.

My Ionic info is

global packages:

    @ionic/cli-plugin-proxy : 1.3.1
    @ionic/cli-utils        : 1.4.0
    Cordova CLI             : 7.0.1
    Ionic CLI               : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.1.2 ios 4.3.1 windows 5.0.0
    Ionic Framework                 : ionic-angular 3.3.0

System:

    Node       : v6.11.0
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10

I actually thought we would want any CPU, but even if I try to build this in Visual Studio I get an error…

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3779	The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.UniversalCRT.Debug, Version=10.0.15063.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM, ARM64".	CordovaApp.Windows10	C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\Microsoft.Cpp.VCLibs120Universal.targets	103	

I will look into this separately, but for now, would like to know how to build with the x86 (or ARM - not sure which I should use to make it generic for any many devices as possible)

Does anyone have any ideas how I can get around this?

Thanks in advance!

So it looks like we need to also provide the --arch parameter, eg

ionic cordova build windows --arch=x86 --release

This still produces an error, but I notice it dopes not seem to pass on the --arch argument, ie it just runs.
cordova build windows --release

If I manually call
cordova build windows --release --arch=x86
then it successfully builds

Same problem facing here.
Passing arch parameter to ionic does not affect cordova build.
Is there a chance to get a fix?

ionic command line:

ionic cordova build windows --prod --release --arch="x86 x64 arm"

executing the following command afterwards is working properly

cordova build windows --release --arch="x86 x64 arm"
cli packages

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 browser 4.1.0 ios 4.4.0 windows 5.0.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 26.0.2
    Node              : v6.10.3
    npm               : 5.3.0
    OS                : Windows 10

Sometimes these commands use -- -- to define params that should be provided to the underlying commands. See the docs: https://ionicframework.com/docs/cli/cordova/build/

Yes, as mentioned by @Sujan12 , this is the case.

So to build windows I use the following

ionic cordova build windows --prod --release -- --arch=x86 

Note the double ‘–’ in the ‘-- --arch=x86’.

That had my stumped for some time.

5 Likes