Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova Build Windows Error - Missing Microsoft.WinJS.2.0

I've been struggling with this for the past 2 hours. I have a simple Ionic/Cordova app that I have working on Android and iOS. I added a windows platform and tried to build and get the following error:

Could not find SDK "Microsoft.WinJS.2.0"

I am using Visual Studio 2015 and am not super familiar, but I attempted to add a reference and it did not work. I tried installing WinJS with npm and that didn't work. I have no idea what to do. Any ideas?

like image 937
Everett Glovier Avatar asked Oct 09 '15 02:10

Everett Glovier


2 Answers

I had the same issue on an app that I'm working on. I am using Windows 10 and Visual Studio 2015. My app works fine on iOS / Android. When adding Windows as a platform, I tried:

cordova platform add windows
cordova build windows

The build step failed with the same error as above:

error MSB3774: Could not find SDK "Microsoft.WinJS.2.0, Version=1.0". 

From Visual Studio, I opened the Solution file and noticed that there are 3 JS projects: one for Windows 8.1, Windows Phone 8.1 and Windows 10.0 Universal. Visual Studio could not run either of the 8.1 projects, even after I tried installing the 8.1 SDKs. However, it had no issue running the Windows 10 Universal project, which packaged its own version of WinJS not dependent on an SDK.

You can change Cordova to target Windows 10 by adding the following line to the config.xml

<preference name="windows-target-version" value="10.0" />

When you run via Cordova, it will install the app locally on your PC, which can be executed like any app from marketplace.

like image 192
raider33 Avatar answered Sep 19 '22 12:09

raider33


The HTML/JS-Apps part of the Windows (Phone) 8.1 SDK is missing. As described in this answer, you can install it as follows:

  • In Visual Studio, click "File" -> "New Project"
  • Select "Windows 8"
  • Double-click "Install Windows 8.1 and Windows Phone 8.0/8.1 tools"
like image 39
Cedric Reichenbach Avatar answered Sep 20 '22 12:09

Cedric Reichenbach