Search code examples
cordovavisual-studio-2015windows-10visual-studio-cordovataco

Building Windows 10 App using Cordova: Set UseDotNetNativeToolchain to false


I'm trying to build a Cordova App using Visual Studio 2015 following this tutorial: http://taco.visualstudio.com/m/docs/tutorial-gulp-readme/,

I set the Windows Target Version in the config.xml to 10.0. When I run gulp, the build task stops with the following error:

C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\Microsoft.NetNative.targets(247,5): error : .NET Native requires an architecture specific Target Platform. Using the 'AnyCPU' Target Platform with .NET Native is not supported. Please ensure the 'UseDotNetNativeToolchain' property is set to false for 'AnyCPU' builds. [E:\App-Path\App-Path\platforms\windows\CordovaApp.Windows10.jsproj]
ERROR: Error code 1 for command: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild with args: E:\App-Path\App-Path\platforms\windows\CordovaApp.Windows10.jsproj,/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal,/nologo,/p:Configuration=release,/p:Platform=anycpu
Process terminated with code 1.

Subsequently, I edited E:\App-Path\App-Path\platforms\windows\CordovaApp.Windows10.jsproj so that it now says

<ProjectConfiguration Include="Release|AnyCPU">
    <Configuration>Release</Configuration>
    <Platform>AnyCPU</Platform>
    <UseDotNetNativeToolchain>false</UseDotNetNativeToolchain>
</ProjectConfiguration>

However, the error still won't go away. What am I doing wrong?


Solution

  • You cannot build for Windows 10 with AnyCPU as your architecture, you must target either x86 or x64.

    To fix this, change your gulp task to build x86 instead of AnyCPU. Here's how I modified the gulp target to work with Windows 10:

    gulp.task("default", function (callback) {
        cordova.build({
            "platforms": ["windows"],
            "options": ["--release", "--archs=x86"]
        }, callback);
    });
    

    If you look at \platforms\windows\cordova\lib\build.js, you'll see the entire list of arguments you can pass to the Windows build task.

    Hope that helps!