Monday, December 2, 2013

Phonegap 3.2 + Windows Phone 8

Locally building Win Phone 8 apps in PhoneGap 3.2.0 with a non-English Windows version will currently always fail and deliver the following error:

>phonegap install wp8
[phonegap] detecting Windows Phone 8 SDK environment...

>phonegap local build wp8
[phonegap] adding the Windows Phone 8 platform...
<snip />
[error] Error while checking requirements: The command `msbuild` failed. Make
 sure you have the latest Windows Phone SDKs installed, AND have the latest .NET
 framework added to your path (i.e C:\Windows\Microsoft.NET\Framework\v4.0.30319
).

This is due to an insufficient regex in line 82 of
<$home>\.cordova\lib\wp\cordova\3.2.0\wp8\bin\check_reqs.js

var msversion = output.match(/Microsoft\s\(R\)\s+Build\sEngine\s[a-z]+\s4\.0\.30319/i);

The regex will match the string "Microsoft (R) Build Engine, Version 4.0.30319" - which is the output of msbuild from the command prompt on Windows Systems (with .NET 4 framework installed) with English locale only.
With German language setting, msbuild says:
Microsoft (R)-Buildmodul, Version 4.0.30319.33440

And that string the above regex will never match and always report that msbuild is missing - no matter whether .NET is installed or not.

Quick Fix: replace the above line with 
var msversion = output.match(/.NET\sFramework\,\s\w*\s4.0/);
This will at least match an installed .NET Framework in Version 4.

Proper Fix: I've reported both to the PhoneGap forum and community.phonegap.com (where they didn't want to see it). 








No comments:

Post a Comment