Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 900D910132 for ; Wed, 9 Apr 2014 22:51:41 +0000 (UTC) Received: (qmail 13069 invoked by uid 500); 9 Apr 2014 22:51:41 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 13014 invoked by uid 500); 9 Apr 2014 22:51:41 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 13005 invoked by uid 99); 9 Apr 2014 22:51:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2014 22:51:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C07A494FF52; Wed, 9 Apr 2014 22:51:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: CB-6341 don't rely on msbuild being in the path. Date: Wed, 9 Apr 2014 22:51:40 +0000 (UTC) Repository: cordova-wp8 Updated Branches: refs/heads/master 1fae9f993 -> 30fba4235 CB-6341 don't rely on msbuild being in the path. Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/30fba423 Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/30fba423 Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/30fba423 Branch: refs/heads/master Commit: 30fba42357f8b6cf2e9a433128369c8f4cc914bb Parents: 1fae9f9 Author: Jesse MacFadyen Authored: Wed Apr 9 15:50:15 2014 -0700 Committer: Jesse MacFadyen Committed: Wed Apr 9 15:50:15 2014 -0700 ---------------------------------------------------------------------- wp7/template/cordova/lib/build.js | 56 +++++++++++++++++++++++++++++++--- wp8/template/cordova/lib/build.js | 56 +++++++++++++++++++++++++++++++--- 2 files changed, 104 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/30fba423/wp7/template/cordova/lib/build.js ---------------------------------------------------------------------- diff --git a/wp7/template/cordova/lib/build.js b/wp7/template/cordova/lib/build.js index bd7c494..1dadbe0 100644 --- a/wp7/template/cordova/lib/build.js +++ b/wp7/template/cordova/lib/build.js @@ -72,6 +72,11 @@ function exec_verbose(command) { } } +// escapes a path so that it can be passed to shell command. +function escapePath(path) { + return '"' + path + '"'; +} + // checks to see if a .csproj file exists in the project root function is_cordova_project(path) { if (fso.FolderExists(path)) { @@ -99,6 +104,21 @@ function get_solution_name(path) { return null; } +// returns full path to msbuild tools required to build the project +function getMSBuildToolsPath() { + // use the latest version of the msbuild tools available on this machine + var toolsVersions = ['4.0']; // for WP7 we REQUIRE 4.0 !!! + for (idx in toolsVersions) { + try { + return wscript_shell.RegRead('HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\' + toolsVersions[idx] + '\\MSBuildToolsPath'); + } catch (err) { + Log("toolsVersion " + idx + " is not supported"); + } + } + Log('MSBuild tools have not been found. Please install Microsoft Visual Studio 2012 or later', true); + WScript.Quit(2); +} + // builds the project and .xap in release mode function build_xap_release(path) { @@ -109,8 +129,22 @@ function build_xap_release(path) { Log("\tDirectory : " + path); wscript_shell.CurrentDirectory = path; - var cmd = 'msbuild "' + get_solution_name(path) + '" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release'; - exec_verbose(cmd); + + var MSBuildToolsPath = getMSBuildToolsPath(); + Log("\tMSBuildToolsPath: " + MSBuildToolsPath); + + var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') + ' ' + escapePath(get_solution_name(path)) + + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release'; + + // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path.. + buildCommand = 'cmd /c "' + buildCommand + '"'; + + Log("buildCommand = " + buildCommand); + + if (exec_verbose(buildCommand) != 0) { + // msbuild failed + WScript.Quit(2); + } // check if file xap was created if (fso.FolderExists(path + '\\Bin\\Release')) { @@ -137,8 +171,22 @@ function build_xap_debug(path) { Log("\tDirectory : " + path); wscript_shell.CurrentDirectory = path; - var cmd = 'msbuild "' + get_solution_name(path) + '" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug'; - exec_verbose(cmd); + + var MSBuildToolsPath = getMSBuildToolsPath(); + Log("\tMSBuildToolsPath: " + MSBuildToolsPath); + + var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') + ' ' + escapePath(get_solution_name(path)) + + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug'; + + // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path.. + buildCommand = '%comspec% /c "' + buildCommand + '"'; + + Log("buildCommand = " + buildCommand); + + if (exec_verbose(buildCommand) != 0) { + // msbuild failed + WScript.Quit(2); + } // check if file xap was created if (fso.FolderExists(path + '\\Bin\\Debug')) { http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/30fba423/wp8/template/cordova/lib/build.js ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/lib/build.js b/wp8/template/cordova/lib/build.js index 2c6406a..c5b3b69 100644 --- a/wp8/template/cordova/lib/build.js +++ b/wp8/template/cordova/lib/build.js @@ -72,6 +72,11 @@ function exec_verbose(command) { } } +// escapes a path so that it can be passed to shell command. +function escapePath(path) { + return '"' + path + '"'; +} + // checks to see if a .csproj file exists in the project root function is_cordova_project(path) { if (fso.FolderExists(path)) { @@ -99,6 +104,21 @@ function get_solution_name(path) { return null; } +// returns full path to msbuild tools required to build the project +function getMSBuildToolsPath() { + // use the latest version of the msbuild tools available on this machine + var toolsVersions = ['12.0','4.0']; // for WP8 we REQUIRE 4.0 !!! + for (idx in toolsVersions) { + try { + return wscript_shell.RegRead('HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\' + toolsVersions[idx] + '\\MSBuildToolsPath'); + } catch (err) { + Log("toolsVersion " + idx + " is not supported"); + } + } + Log('MSBuild tools have not been found. Please install Microsoft Visual Studio 2012 or later', true); + WScript.Quit(2); +} + // builds the project and .xap in release mode function build_xap_release(path) { @@ -109,8 +129,22 @@ function build_xap_release(path) { Log("\tDirectory : " + path); wscript_shell.CurrentDirectory = path; - var cmd = 'msbuild "' + get_solution_name(path) + '" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release'; - exec_verbose(cmd); + + var MSBuildToolsPath = getMSBuildToolsPath(); + Log("\tMSBuildToolsPath: " + MSBuildToolsPath); + + var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') + ' ' + escapePath(get_solution_name(path)) + + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release'; + + // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path.. + buildCommand = 'cmd /c "' + buildCommand + '"'; + + Log("buildCommand = " + buildCommand); + + if (exec_verbose(buildCommand) != 0) { + // msbuild failed + WScript.Quit(2); + } // check if file xap was created if (fso.FolderExists(path + '\\Bin\\Release')) { @@ -137,8 +171,22 @@ function build_xap_debug(path) { Log("\tDirectory : " + path); wscript_shell.CurrentDirectory = path; - var cmd = 'msbuild "' + get_solution_name(path) + '" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug'; - exec_verbose(cmd); + + var MSBuildToolsPath = getMSBuildToolsPath(); + Log("\tMSBuildToolsPath: " + MSBuildToolsPath); + + var buildCommand = escapePath(MSBuildToolsPath + 'msbuild') + ' ' + escapePath(get_solution_name(path)) + + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug'; + + // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path.. + buildCommand = '%comspec% /c "' + buildCommand + '"'; + + Log("buildCommand = " + buildCommand); + + if (exec_verbose(buildCommand) != 0) { + // msbuild failed + WScript.Quit(2); + } // check if file xap was created if (fso.FolderExists(path + '\\Bin\\Debug')) {