You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by bi...@apache.org on 2014/05/09 09:22:33 UTC

[24/24] git commit: a) Convert all the DataJS supported functionality from V3 to V4. 1. Remove all the Json verbose logic, make the DataJS accepted and returned javascript object be in Json light format. (Since Json verbose has been completely removed on

a) Convert all the DataJS supported functionality from V3 to V4.
1. Remove all the Json verbose logic, make the DataJS accepted and returned javascript object be in Json light format. (Since Json verbose has been completely removed on V4, making the javascript object returned by DataJS in json verbose format doesn’t make sense any more. )
2. Add the supports for parsing and setting the changed and new added headers in the request/response.
3. Parse OData V4 Metadata payload.
4. Make the DataJS cache and storage components work.

Batch payload parser and serializer. (Note: “Serializer” means serializing javascript object to the string payload which could be posted to OData service side, while “Parser” means converting the odata payload string to javascript object.)


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/commit/e387fc92
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/e387fc92
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/e387fc92

Branch: refs/heads/OLINGO-276
Commit: e387fc9295b716b62c9fbdae5b1d80c39cfcce50
Parents: a84a42d
Author: dingeins <yi...@foxmail.com>
Authored: Fri May 9 15:22:03 2014 +0800
Committer: dingeins <yi...@foxmail.com>
Committed: Fri May 9 15:22:03 2014 +0800

----------------------------------------------------------------------
 BuildTools/ajaxmin/readme.txt                   |    4 +-
 BuildTools/djsbuild.cmd                         |  270 +-
 BuildTools/djsbuildfile.js                      |  370 +-
 BuildTools/djsbuildfile.wsf                     |   32 +-
 BuildTools/djsbuildver.cmd                      |   32 +-
 BuildTools/djscommon.js                         | 1042 +-
 BuildTools/djslicense.js                        |   24 +-
 BuildTools/djspatchtests.js                     |  108 +-
 BuildTools/djspatchtests.wsf                    |   26 +-
 JSLib/JSLib.csproj                              |  318 +-
 JSLib/JSLib.sln                                 |   38 +-
 JSLib/Web.config                                |   66 +-
 JSLib/src/cache-source.js                       |  378 +-
 JSLib/src/cache.js                              | 2708 ++---
 JSLib/src/datajs.js                             |  120 +-
 JSLib/src/deferred.js                           |  356 +-
 JSLib/src/odata-atom.js                         | 2820 +++---
 JSLib/src/odata-batch.js                        |  784 +-
 JSLib/src/odata-gml.js                          | 1660 +--
 JSLib/src/odata-handler.js                      |  550 +-
 JSLib/src/odata-json-light.js                   | 2833 +++---
 JSLib/src/odata-json.js                         |  717 +-
 JSLib/src/odata-metadata.js                     | 1014 +-
 JSLib/src/odata-net.js                          |  659 +-
 JSLib/src/odata-utils.js                        | 2249 +++--
 JSLib/src/odata-xml.js                          | 1685 ++--
 JSLib/src/odata.js                              |  311 +-
 JSLib/src/store-dom.js                          |  638 +-
 JSLib/src/store-indexeddb.js                    |  832 +-
 JSLib/src/store-memory.js                       |  460 +-
 JSLib/src/store.js                              |  120 +-
 JSLib/src/utils.js                              | 1035 +-
 JSLib/src/xml.js                                | 1646 +--
 JSLib/tests/code/ReflectionDataContext.cs       | 1482 +--
 JSLib/tests/code/atomreader.cs                  | 1590 +--
 JSLib/tests/code/csdlreader.cs                  |  415 +-
 JSLib/tests/code/jsdate.cs                      |   78 +-
 JSLib/tests/code/jsonobject.cs                  |  158 +-
 JSLib/tests/code/readerutils.cs                 |  114 +-
 JSLib/tests/common/ODataReadOracle.js           |  478 +-
 JSLib/tests/common/ODataReadOracle.svc          |  369 +-
 JSLib/tests/common/TestLogger.svc               | 1690 ++--
 JSLib/tests/common/TestSynchronizerClient.js    |  434 +-
 JSLib/tests/common/djstest.js                   |  807 +-
 JSLib/tests/endpoints/FoodStoreDataService.svc  |  860 +-
 .../tests/endpoints/FoodStoreDataServiceV2.svc  |  884 +-
 .../tests/endpoints/FoodStoreDataServiceV3.svc  | 1166 +--
 JSLib/tests/endpoints/web.config                |   53 +-
 JSLib/tests/odata-atom-tests.js                 | 9499 +++++++++---------
 JSLib/tests/odata-qunit-tests.htm               |  174 +-
 JSLib/tests/run-tests.wsf                       |  852 +-
 JSLib/tests/test-list.js                        |   38 +-
 52 files changed, 23569 insertions(+), 23477 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/ajaxmin/readme.txt
----------------------------------------------------------------------
diff --git a/BuildTools/ajaxmin/readme.txt b/BuildTools/ajaxmin/readme.txt
index c74506c..cf1619c 100644
--- a/BuildTools/ajaxmin/readme.txt
+++ b/BuildTools/ajaxmin/readme.txt
@@ -1,2 +1,2 @@
-To enable the DataJS library to be minified, download the Ajax Minifier from
-http://ajaxmin.codeplex.com/ and copy the binaries into %DJSROOT%\BuildTools\ajaxmin
+To enable the DataJS library to be minified, download the Ajax Minifier from
+http://ajaxmin.codeplex.com/ and copy the binaries into %DJSROOT%\BuildTools\ajaxmin

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djsbuild.cmd
----------------------------------------------------------------------
diff --git a/BuildTools/djsbuild.cmd b/BuildTools/djsbuild.cmd
index 0e17f63..ba7261c 100644
--- a/BuildTools/djsbuild.cmd
+++ b/BuildTools/djsbuild.cmd
@@ -1,136 +1,136 @@
-@echo off
-
-rem Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-rem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
-rem files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-rem modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
-rem Software is furnished to do so, subject to the following conditions:
-rem 
-rem The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-rem 
-rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-rem WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-rem COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
-rem ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-setlocal    
-
-
-if "%DJSROOT%" == "" (
-  echo Please set the DJSROOT environment variable for the build process.
-  exit /b 1
-)
-
-if "%DJSOUT%" == "" (
-  echo Please set the DJSOUT environment variable for the build process.
-  exit /b 1
-)
-
-rem Build overview:
-rem 1. Call msbuild to generate the webapplication bin directory.
-rem 2. All solution files are copied or merged into the output directory.
-rem 3. Internal references are removed from the merged file (eg, ODATA_INTERNAL).
-rem    This produces datajs.js.
-rem 4. The minifier is run. This produces datajs.min.js.
-rem 5. The files are renamed to the version-specific filenames.
-
-echo Invoking msbuild...
-where /Q msbuild.exe
-if errorlevel 1 (
-    echo Please add the path to msbuild.exe to the Path environment variable for the build process.
-    exit /b 1
-)
-msbuild /nologo /clp:DisableConsoleColor /target:rebuild "%DJSROOT%\JSLib\JSLib.sln"
-
-echo Building internal datajs version...
-cscript "%DJSROOT%\BuildTools\djsbuildfile.wsf" //Nologo /build-solution:true /out:"%DJSOUT%" "%DJSROOT%\JSLib\JSLib.sln"
-if errorlevel 1 (
-  exit /b %errorlevel%
-)
-
-if exist "%DJSOUT%\jslib.sln\src\datajs.merged.js" (
-  del "%DJSOUT%\jslib.sln\src\datajs.merged.js"
-  if errorlevel 1 (
-    exit /b %errorlevel%
-  )
-)
-
-ren "%DJSOUT%\jslib.sln\src\datajs.js" datajs.merged.js
-if errorlevel 1 (
-  exit /b %errorlevel%
-)
-
-echo.
-echo Removing internal references...
-cscript "%DJSROOT%\BuildTools\djsbuildfile.wsf" //Nologo /remove-internals:true /out:"%DJSOUT%\jslib.sln\src\datajs.js" "%DJSOUT%\jslib.sln\src\datajs.merged.js"
-if errorlevel 1 (
-  exit /b %errorlevel%
-)
-
-echo.
-echo Minifying output file...
-if exist "%DJSROOT%\BuildTools\ajaxmin\AjaxMin.exe" (
-  "%DJSROOT%\BuildTools\ajaxmin\AjaxMin.exe" -JS -debug:false -analyze -clobber:true "%DJSOUT%\jslib.sln\src\datajs.js" -out "%DJSOUT%\jslib.sln\src\datajs.min.body.js" > "%DJSOUT%\jslib.sln\src\datajs.js.log" 2>&1
-  if errorlevel 1 (
-    echo Error when running AjaxMin.exe on "%DJSOUT%\jslib.sln\src\datajs.js"
-    echo See log at "%DJSOUT%\jslib.sln\src\datajs.js.log"
-    exit /b 1
-  )
-
-  copy "%DJSROOT%\BuildTools\djslicense.js" /B +"%DJSOUT%\jslib.sln\src\datajs.min.body.js" /B "%DJSOUT%\jslib.sln\src\datajs.min.js" /B
-  del /Q "%DJSOUT%\jslib.sln\src\datajs.min.body.js"
-  
-) else (
-  type "%DJSROOT%\BuildTools\ajaxmin\readme.txt"
-  echo.
-  echo Using non-minified file instead.
-  copy /y "%DJSOUT%\jslib.sln\src\datajs.js" "%DJSOUT%\jslib.sln\src\datajs.min.js"
-)
-
-
-call "%DJSROOT%\BuildTools\djsbuildver.cmd"
-
-if exist "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.js" (
-  del /q "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.js"
-  if errorlevel 1 (
-    exit /b %errorlevel%
-  )
-)
-
-if exist "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.min.js" (
-  del /q "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.min.js"
-  if errorlevel 1 (
-    exit /b %errorlevel%
-  )
-)
-
-ren "%DJSOUT%\jslib.sln\src\datajs.js" datajs-%DJSVER%.js
-ren "%DJSOUT%\jslib.sln\src\datajs.min.js" datajs-%DJSVER%.min.js
-
-echo.
-echo Redirecting unit tests to internal file...
-cscript "%DJSROOT%\BuildTools\djspatchtests.wsf" //Nologo /in:"%DJSOUT%\jslib.sln\tests" /replace-script:"../src/datajs.merged.js"
-if errorlevel 1 (
-   exit /b %errorlevel%
-)
-
-echo.
-echo Copying bin folder...
-robocopy "%DJSROOT%\JSLib\bin" "%DJSOUT%\jslib.sln\bin" /E /R:10 1>NUL
-
-if errorlevel 8 (
-    exit /b %errorlevel%
-)
-
-if errorlevel 16 (
-    exit /b %errorlevel%
-)
-
-echo.
-echo The built files are:
-echo %DJSOUT%\jslib.sln\src\datajs-%DJSVER%.js     - development version
-echo %DJSOUT%\jslib.sln\src\datajs-%DJSVER%.min.js - minified version
-
-endlocal
-
+@echo off
+
+rem Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
+rem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
+rem files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
+rem modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
+rem Software is furnished to do so, subject to the following conditions:
+rem 
+rem The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+rem 
+rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+rem WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+rem COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
+rem ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+setlocal    
+
+
+if "%DJSROOT%" == "" (
+  echo Please set the DJSROOT environment variable for the build process.
+  exit /b 1
+)
+
+if "%DJSOUT%" == "" (
+  echo Please set the DJSOUT environment variable for the build process.
+  exit /b 1
+)
+
+rem Build overview:
+rem 1. Call msbuild to generate the webapplication bin directory.
+rem 2. All solution files are copied or merged into the output directory.
+rem 3. Internal references are removed from the merged file (eg, ODATA_INTERNAL).
+rem    This produces datajs.js.
+rem 4. The minifier is run. This produces datajs.min.js.
+rem 5. The files are renamed to the version-specific filenames.
+
+echo Invoking msbuild...
+where /Q msbuild.exe
+if errorlevel 1 (
+    echo Please add the path to msbuild.exe to the Path environment variable for the build process.
+    exit /b 1
+)
+msbuild /nologo /clp:DisableConsoleColor /target:rebuild "%DJSROOT%\JSLib\JSLib.sln"
+
+echo Building internal datajs version...
+cscript "%DJSROOT%\BuildTools\djsbuildfile.wsf" //Nologo /build-solution:true /out:"%DJSOUT%" "%DJSROOT%\JSLib\JSLib.sln"
+if errorlevel 1 (
+  exit /b %errorlevel%
+)
+
+if exist "%DJSOUT%\jslib.sln\src\datajs.merged.js" (
+  del "%DJSOUT%\jslib.sln\src\datajs.merged.js"
+  if errorlevel 1 (
+    exit /b %errorlevel%
+  )
+)
+
+ren "%DJSOUT%\jslib.sln\src\datajs.js" datajs.merged.js
+if errorlevel 1 (
+  exit /b %errorlevel%
+)
+
+echo.
+echo Removing internal references...
+cscript "%DJSROOT%\BuildTools\djsbuildfile.wsf" //Nologo /remove-internals:true /out:"%DJSOUT%\jslib.sln\src\datajs.js" "%DJSOUT%\jslib.sln\src\datajs.merged.js"
+if errorlevel 1 (
+  exit /b %errorlevel%
+)
+
+echo.
+echo Minifying output file...
+if exist "%DJSROOT%\BuildTools\ajaxmin\AjaxMin.exe" (
+  "%DJSROOT%\BuildTools\ajaxmin\AjaxMin.exe" -JS -debug:false -analyze -clobber:true "%DJSOUT%\jslib.sln\src\datajs.js" -out "%DJSOUT%\jslib.sln\src\datajs.min.body.js" > "%DJSOUT%\jslib.sln\src\datajs.js.log" 2>&1
+  if errorlevel 1 (
+    echo Error when running AjaxMin.exe on "%DJSOUT%\jslib.sln\src\datajs.js"
+    echo See log at "%DJSOUT%\jslib.sln\src\datajs.js.log"
+    exit /b 1
+  )
+
+  copy "%DJSROOT%\BuildTools\djslicense.js" /B +"%DJSOUT%\jslib.sln\src\datajs.min.body.js" /B "%DJSOUT%\jslib.sln\src\datajs.min.js" /B
+  del /Q "%DJSOUT%\jslib.sln\src\datajs.min.body.js"
+  
+) else (
+  type "%DJSROOT%\BuildTools\ajaxmin\readme.txt"
+  echo.
+  echo Using non-minified file instead.
+  copy /y "%DJSOUT%\jslib.sln\src\datajs.js" "%DJSOUT%\jslib.sln\src\datajs.min.js"
+)
+
+
+call "%DJSROOT%\BuildTools\djsbuildver.cmd"
+
+if exist "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.js" (
+  del /q "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.js"
+  if errorlevel 1 (
+    exit /b %errorlevel%
+  )
+)
+
+if exist "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.min.js" (
+  del /q "%DJSOUT%\jslib.sln\src\datajs-%DJSVER%.min.js"
+  if errorlevel 1 (
+    exit /b %errorlevel%
+  )
+)
+
+ren "%DJSOUT%\jslib.sln\src\datajs.js" datajs-%DJSVER%.js
+ren "%DJSOUT%\jslib.sln\src\datajs.min.js" datajs-%DJSVER%.min.js
+
+echo.
+echo Redirecting unit tests to internal file...
+cscript "%DJSROOT%\BuildTools\djspatchtests.wsf" //Nologo /in:"%DJSOUT%\jslib.sln\tests" /replace-script:"../src/datajs.merged.js"
+if errorlevel 1 (
+   exit /b %errorlevel%
+)
+
+echo.
+echo Copying bin folder...
+robocopy "%DJSROOT%\JSLib\bin" "%DJSOUT%\jslib.sln\bin" /E /R:10 1>NUL
+
+if errorlevel 8 (
+    exit /b %errorlevel%
+)
+
+if errorlevel 16 (
+    exit /b %errorlevel%
+)
+
+echo.
+echo The built files are:
+echo %DJSOUT%\jslib.sln\src\datajs-%DJSVER%.js     - development version
+echo %DJSOUT%\jslib.sln\src\datajs-%DJSVER%.min.js - minified version
+
+endlocal
+
 exit /b 0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djsbuildfile.js
----------------------------------------------------------------------
diff --git a/BuildTools/djsbuildfile.js b/BuildTools/djsbuildfile.js
index d31ae85..27ec73c 100644
--- a/BuildTools/djsbuildfile.js
+++ b/BuildTools/djsbuildfile.js
@@ -1,186 +1,186 @@
-/// <reference path="djscommon.js" />
-
-// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-var markerFormats = {};
-
-markerFormats[".js"] = "// MARKER";
-markerFormats[".html"] = "<!-- MARKER -->";
-markerFormats[".htm"] = markerFormats[".html"];
-
-function MakeMarker(ext, marker) {
-    /// <summary>Builds the appropriate marker string based on the file extension.</summary>
-    /// <param name="ext" type="String">Extension of the file for which the marker string is going to be generated.</param>
-    /// <param name="marker" type="String">Text to be contained in the marker.</param>
-    /// <returns type="String">Specific marker string.</returns>
-
-    var format = markerFormats[ext.toLowerCase()];
-    if (format) {
-        return format.replace("MARKER", marker);
-    }
-    return null;
-}
-
-function BuildFromProject(path, outBasePath) {
-    // Read the csproj.
-    WScript.Echo("Reading project " + path);
-    var xml = new ActiveXObject("Msxml2.DOMDocument.6.0");
-    xml.load(path);
-    xml.setProperty("SelectionNamespaces", "xmlns:msb='http://schemas.microsoft.com/developer/msbuild/2003'");
-    xml.setProperty("SelectionLanguage", "XPath");
-
-    var files = xml.selectNodes("//msb:ItemGroup/*[not(self::msb:Reference)]/@Include");
-    var fileIncludes = {};
-    var i, len, filePath;
-
-    // Get file dependencies.
-    for (i = 0, len = files.length; i < len; i++) {
-        filePath = PathCombine(PathGetDirectory(path), files[i].value);
-        if (FileExists(filePath)) {
-            var includes = GetFileIncludes(filePath);
-            var j, includeLen;
-            for (j = 0, includeLen = includes.length; j < includeLen; j++) {
-                fileIncludes[includes[j]] = {};
-            }
-        } else if (!FolderExists(filePath)) {
-            throw { message: "path doesn't exist " + filePath };
-        }
-    }
-
-    // Build the files that are not in the dependency list.
-    for (i = 0, len = files.length; i < len; i++) {
-        filePath = PathCombine(PathGetDirectory(path), files[i].value);
-        var outputPath = PathCombine(outBasePath, files[i].value);
-        if (!fileIncludes[filePath] && !FolderExists(filePath)) {
-            BuildFile(filePath, outputPath);
-        }
-    }
-}
-
-function GetFileIncludes(path) {
-    var content = ReadAllTextFile(path);
-    var lines = StringSplit(content, "\r\n");
-    var result = [];
-    var i, len;
-    for (i = 0, len = lines.length; i < len; i++) {
-        var line = lines[i];
-        var includeIndex = line.indexOf("// INCLUDE:");
-        if (includeIndex !== -1) {
-            var anotherPath = line.substr(includeIndex + 11);
-            anotherPath = anotherPath.replace(/^\s+|\s+$/g, "");
-            if (!FileExists(anotherPath)) {
-                anotherPath = PathGetDirectory(path) + "\\" + anotherPath;
-            }
-            result.push(GetFileIncludes(anotherPath));
-            result.push(anotherPath);
-        }
-    }
-
-    return result;
-}
-
-// TODO: provide support for composing relative paths.
-function BuildFromSln(path, outBasePath) {
-    WScript.Echo("Reading solution " + path);
-    var outPath = PathCombine(outBasePath, PathGetFileName(path));
-    var regEx = /(Project\("[^"]+"\)\s*=\s*)"([^"]+)"\s*,\s*"([^"]+)"/;
-    var content = ReadAllTextFile(path);
-    var lines = StringSplit(content, "\r\n");
-    var i, len;
-    for (i = 0, len = lines.length; i < len; i++) {
-        var matches = regEx.exec(lines[i]);
-        if (matches) {
-            var projectPath = PathCombine(PathGetDirectory(path), matches[3]);
-            BuildFromProject(projectPath, outPath);
-        }
-    }
-}
-
-function BuildFile(path, outPath) {
-    /// <summary>Builds a JavaScript file. </summary>
-    /// <param name="path" type="String">Path to the file whose content is going to be built.</param>
-    /// <param name="outPath" type="String">Path of the built file.</param>
-
-    if (!FileExists(path)) {
-        throw { message: "File does not exist: " + inName };
-    }
-
-    CreateFolderIfMissing(PathGetDirectory(outPath));
-    switch (PathGetExtension(path).toLowerCase()) {
-        case ".js":
-        case ".htm":
-        case ".html":
-            WScript.Echo("building file: " + path);
-            var built = BuildFileForContent(path, false);
-            SaveTextToFile(built, outPath);
-            break;
-        default:
-            WScript.Echo("copying file: " + path);
-            CopyFile(path, outPath, true);
-            break;
-    }
-}
-
-function BuildFileForContent(path, contentOnly) {
-    var ext = PathGetExtension(path);
-    var includeCallback = function (line, inContent) {    
-        var includeIndex = line.indexOf(MakeMarker(ext, "INCLUDE: "));
-        if (includeIndex !== -1) {
-            var anotherPath = line.substr(includeIndex + 11);
-            anotherPath = anotherPath.replace(/^\s+|\s+$/g, "");
-            if (!FileExists(anotherPath)) {
-                anotherPath = PathGetDirectory(path) + "\\" + anotherPath;
-            }
-
-            return BuildFileForContent(anotherPath, true);
-        } else {
-            return (inContent) ? line : null;
-        }
-    };
-
-    return ExtractContentsBetweenMarkers(path, contentOnly, /*isExclusion*/ false, 
-        MakeMarker(ext, "CONTENT START"), MakeMarker(ext, "CONTENT END"), includeCallback);
-}
-
-function RemoveInternals(inName, outName) {
-    var ext = PathGetExtension(inName);
-    var includeCallback = function (line, inContent) {
-        return (line.indexOf("djsassert") === -1) ? line : null;
-    };
-    var content = ExtractContentsBetweenMarkers(inName, true, /*isExclusion*/ true,
-        MakeMarker(ext, "DATAJS INTERNAL START"), MakeMarker(ext, "DATAJS INTERNAL END"), includeCallback);
-    
-    SaveTextToFile(content, outName);
-}
-
-RunAndQuit(function () {
-    var args = WScript.Arguments;
-    var inName = WScript.Arguments.Unnamed(0);
-    if (!inName) {
-        throw { message: "no input specified" };
-    }
-
-    var outName = WScript.Arguments.Named("out");
-    if (!outName) {
-        throw { message: "no output specified" };
-    }
-
-    if (CheckScriptFlag("build-solution")) {
-        BuildFromSln(inName, outName);
-    }
-    if (CheckScriptFlag("remove-internals")) {
-        RemoveInternals(inName, outName);
-    }
+/// <reference path="djscommon.js" />
+
+// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
+// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+var markerFormats = {};
+
+markerFormats[".js"] = "// MARKER";
+markerFormats[".html"] = "<!-- MARKER -->";
+markerFormats[".htm"] = markerFormats[".html"];
+
+function MakeMarker(ext, marker) {
+    /// <summary>Builds the appropriate marker string based on the file extension.</summary>
+    /// <param name="ext" type="String">Extension of the file for which the marker string is going to be generated.</param>
+    /// <param name="marker" type="String">Text to be contained in the marker.</param>
+    /// <returns type="String">Specific marker string.</returns>
+
+    var format = markerFormats[ext.toLowerCase()];
+    if (format) {
+        return format.replace("MARKER", marker);
+    }
+    return null;
+}
+
+function BuildFromProject(path, outBasePath) {
+    // Read the csproj.
+    WScript.Echo("Reading project " + path);
+    var xml = new ActiveXObject("Msxml2.DOMDocument.6.0");
+    xml.load(path);
+    xml.setProperty("SelectionNamespaces", "xmlns:msb='http://schemas.microsoft.com/developer/msbuild/2003'");
+    xml.setProperty("SelectionLanguage", "XPath");
+
+    var files = xml.selectNodes("//msb:ItemGroup/*[not(self::msb:Reference)]/@Include");
+    var fileIncludes = {};
+    var i, len, filePath;
+
+    // Get file dependencies.
+    for (i = 0, len = files.length; i < len; i++) {
+        filePath = PathCombine(PathGetDirectory(path), files[i].value);
+        if (FileExists(filePath)) {
+            var includes = GetFileIncludes(filePath);
+            var j, includeLen;
+            for (j = 0, includeLen = includes.length; j < includeLen; j++) {
+                fileIncludes[includes[j]] = {};
+            }
+        } else if (!FolderExists(filePath)) {
+            throw { message: "path doesn't exist " + filePath };
+        }
+    }
+
+    // Build the files that are not in the dependency list.
+    for (i = 0, len = files.length; i < len; i++) {
+        filePath = PathCombine(PathGetDirectory(path), files[i].value);
+        var outputPath = PathCombine(outBasePath, files[i].value);
+        if (!fileIncludes[filePath] && !FolderExists(filePath)) {
+            BuildFile(filePath, outputPath);
+        }
+    }
+}
+
+function GetFileIncludes(path) {
+    var content = ReadAllTextFile(path);
+    var lines = StringSplit(content, "\r\n");
+    var result = [];
+    var i, len;
+    for (i = 0, len = lines.length; i < len; i++) {
+        var line = lines[i];
+        var includeIndex = line.indexOf("// INCLUDE:");
+        if (includeIndex !== -1) {
+            var anotherPath = line.substr(includeIndex + 11);
+            anotherPath = anotherPath.replace(/^\s+|\s+$/g, "");
+            if (!FileExists(anotherPath)) {
+                anotherPath = PathGetDirectory(path) + "\\" + anotherPath;
+            }
+            result.push(GetFileIncludes(anotherPath));
+            result.push(anotherPath);
+        }
+    }
+
+    return result;
+}
+
+// TODO: provide support for composing relative paths.
+function BuildFromSln(path, outBasePath) {
+    WScript.Echo("Reading solution " + path);
+    var outPath = PathCombine(outBasePath, PathGetFileName(path));
+    var regEx = /(Project\("[^"]+"\)\s*=\s*)"([^"]+)"\s*,\s*"([^"]+)"/;
+    var content = ReadAllTextFile(path);
+    var lines = StringSplit(content, "\r\n");
+    var i, len;
+    for (i = 0, len = lines.length; i < len; i++) {
+        var matches = regEx.exec(lines[i]);
+        if (matches) {
+            var projectPath = PathCombine(PathGetDirectory(path), matches[3]);
+            BuildFromProject(projectPath, outPath);
+        }
+    }
+}
+
+function BuildFile(path, outPath) {
+    /// <summary>Builds a JavaScript file. </summary>
+    /// <param name="path" type="String">Path to the file whose content is going to be built.</param>
+    /// <param name="outPath" type="String">Path of the built file.</param>
+
+    if (!FileExists(path)) {
+        throw { message: "File does not exist: " + inName };
+    }
+
+    CreateFolderIfMissing(PathGetDirectory(outPath));
+    switch (PathGetExtension(path).toLowerCase()) {
+        case ".js":
+        case ".htm":
+        case ".html":
+            WScript.Echo("building file: " + path);
+            var built = BuildFileForContent(path, false);
+            SaveTextToFile(built, outPath);
+            break;
+        default:
+            WScript.Echo("copying file: " + path);
+            CopyFile(path, outPath, true);
+            break;
+    }
+}
+
+function BuildFileForContent(path, contentOnly) {
+    var ext = PathGetExtension(path);
+    var includeCallback = function (line, inContent) {    
+        var includeIndex = line.indexOf(MakeMarker(ext, "INCLUDE: "));
+        if (includeIndex !== -1) {
+            var anotherPath = line.substr(includeIndex + 11);
+            anotherPath = anotherPath.replace(/^\s+|\s+$/g, "");
+            if (!FileExists(anotherPath)) {
+                anotherPath = PathGetDirectory(path) + "\\" + anotherPath;
+            }
+
+            return BuildFileForContent(anotherPath, true);
+        } else {
+            return (inContent) ? line : null;
+        }
+    };
+
+    return ExtractContentsBetweenMarkers(path, contentOnly, /*isExclusion*/ false, 
+        MakeMarker(ext, "CONTENT START"), MakeMarker(ext, "CONTENT END"), includeCallback);
+}
+
+function RemoveInternals(inName, outName) {
+    var ext = PathGetExtension(inName);
+    var includeCallback = function (line, inContent) {
+        return (line.indexOf("djsassert") === -1) ? line : null;
+    };
+    var content = ExtractContentsBetweenMarkers(inName, true, /*isExclusion*/ true,
+        MakeMarker(ext, "DATAJS INTERNAL START"), MakeMarker(ext, "DATAJS INTERNAL END"), includeCallback);
+    
+    SaveTextToFile(content, outName);
+}
+
+RunAndQuit(function () {
+    var args = WScript.Arguments;
+    var inName = WScript.Arguments.Unnamed(0);
+    if (!inName) {
+        throw { message: "no input specified" };
+    }
+
+    var outName = WScript.Arguments.Named("out");
+    if (!outName) {
+        throw { message: "no output specified" };
+    }
+
+    if (CheckScriptFlag("build-solution")) {
+        BuildFromSln(inName, outName);
+    }
+    if (CheckScriptFlag("remove-internals")) {
+        RemoveInternals(inName, outName);
+    }
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djsbuildfile.wsf
----------------------------------------------------------------------
diff --git a/BuildTools/djsbuildfile.wsf b/BuildTools/djsbuildfile.wsf
index e8006f5..2913a83 100644
--- a/BuildTools/djsbuildfile.wsf
+++ b/BuildTools/djsbuildfile.wsf
@@ -1,17 +1,17 @@
-<package>
-  <job>
-    <runtime>
-      <description>
-      This script is used to process files from the datajs project
-      into a variety of output script files.
-      </description>
-      <unnamed name="in" helpstring="Input to process" type="string" required="true" />
-      <named name="out" helpstring="Path to directory for output files." type="string" required="true" />
-      <named name="build-solution" helpstring="Builds the solution input by coalescing scripts." type="string" required="false" />
-      <named name="remove-internals" helpstring="Removes internal references from the input." type="string" required="false" />
-      <example>cscript djsbuildfile.wsf //Nologo /out:%djsroot%\JSLib\JSLib.sln /in:%djsroot%\out</example>
-    </runtime>
-    <script language="JScript" src="djscommon.js" />
-    <script language="JScript" src="djsbuildfile.js" />
-  </job>
+<package>
+  <job>
+    <runtime>
+      <description>
+      This script is used to process files from the datajs project
+      into a variety of output script files.
+      </description>
+      <unnamed name="in" helpstring="Input to process" type="string" required="true" />
+      <named name="out" helpstring="Path to directory for output files." type="string" required="true" />
+      <named name="build-solution" helpstring="Builds the solution input by coalescing scripts." type="string" required="false" />
+      <named name="remove-internals" helpstring="Removes internal references from the input." type="string" required="false" />
+      <example>cscript djsbuildfile.wsf //Nologo /out:%djsroot%\JSLib\JSLib.sln /in:%djsroot%\out</example>
+    </runtime>
+    <script language="JScript" src="djscommon.js" />
+    <script language="JScript" src="djsbuildfile.js" />
+  </job>
 </package>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djsbuildver.cmd
----------------------------------------------------------------------
diff --git a/BuildTools/djsbuildver.cmd b/BuildTools/djsbuildver.cmd
index 279e499..bb22a40 100644
--- a/BuildTools/djsbuildver.cmd
+++ b/BuildTools/djsbuildver.cmd
@@ -1,16 +1,16 @@
-@echo off
-
-rem Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-rem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
-rem files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-rem modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
-rem Software is furnished to do so, subject to the following conditions:
-rem 
-rem The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-rem 
-rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-rem WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-rem COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
-rem ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-set DJSVER=1.1.2
\ No newline at end of file
+@echo off
+
+rem Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
+rem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
+rem files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
+rem modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
+rem Software is furnished to do so, subject to the following conditions:
+rem 
+rem The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+rem 
+rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+rem WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+rem COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
+rem ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+set DJSVER=2.0.0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djscommon.js
----------------------------------------------------------------------
diff --git a/BuildTools/djscommon.js b/BuildTools/djscommon.js
index ca779bb..6c5f45f 100644
--- a/BuildTools/djscommon.js
+++ b/BuildTools/djscommon.js
@@ -1,522 +1,522 @@
-// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-//
-// References:
-//
-// JScript Language Reference
-// http://msdn2.microsoft.com/en-us/library/yek4tbz0
-//
-// Windows Script Host Object Model
-// http://msdn2.microsoft.com/en-us/library/a74hyyw0
-//
-// Script Runtime
-// http://msdn2.microsoft.com/en-us/library/hww8txat.aspx
-//
-
-function ArrayAny(arr, callback) {
-    /// <summary>Checks whether any element in an array satisfies a predicate.</summary>
-    /// <param name="arr" type="Array">Array to operate on.</param>
-    /// <param name="callback" type="Function">Function to test with element and index, returning true or false.</param>
-    /// <returns type="Boolean">true if 'callback' returns true for any element; false otherwise.</returns>
-    for (var i = 0; i < arr.length; i++) {
-        if (callback(arr[i], i)) {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-function ArrayWhere(arr, callback) {
-    /// <summary>Returns the elements in an array that satisfy a predicate.</summary>
-    /// <param name="arr" type="Array">Array to operate on.</param>
-    /// <param name="callback" type="Function">Function to test with element and index, returning true or false.</param>
-    /// <returns type="Array">Array of elements from arr that satisfy the predicate.</returns>
-
-    var result = [];
-
-    for (var i = 0; i < arr.length; i++) {
-        if (callback(arr[i], i)) {
-            result.push(arr[i]);
-        }
-    }
-    return result;
-}
-
-function ArrayForEach(arr, callback) {
-    /// <summary>Invokes a callback for each element in the array.</summary>
-    /// <param name="arr" type="Array">Array to operate on.</param>
-    /// <param name="callback" type="Function">Function to invoke with element and index.</param>
-    for (var i = 0; i < arr.length; i++) {
-        callback(arr[i], i);
-    }
-}
-
-function CheckScriptFlag(name) {
-    /// <summary>Checks whether a script argument was given with true or false.</summary>
-    /// <param name="name" type="String">Argument name to check.</param>
-    /// <returns type="Boolean">
-    /// true if the argument was given witha value of 'true' or 'True'; false otherwise.
-    /// </returns>
-    var flag = WScript.Arguments.Named(name);
-    if (!flag) {
-        return false;
-    }
-
-    return flag === "true" || flag === "True";
-}
-
-function CreateFolderIfMissing(path) {
-    /// <summary>Creates a folder if it doesn't exist.</summary>
-    /// <param name="path" type="String">Path to folder to create.</param>
-    /// <remarks>This function will write out to the console on creation.</remarks>
-    if (!path) return;
-    var parent = PathGetDirectory(path);
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    if (!fso.FolderExists(parent)) {
-        CreateFolderIfMissing(parent);
-    }
-    if (!fso.FolderExists(path)) {
-        WScript.Echo("Creating " + path + "...");
-        fso.CreateFolder(path);
-    }
-}
-
-function DeleteFile(path, force) {
-    /// <summary>Deletes a file.</summary>
-    /// <param name="path" type="String">Path to the file.</param>
-    /// <param name="force" type="Boolean">Whether to delete the file even if it has the read-only attribute set.</param>
-
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    fso.DeleteFile(path, force);
-}
-
-function DeleteFolder(path, force) {
-    /// <summary>Deletes a folder.</summary>
-    /// <param name="path" type="String">Path to the folder.</param>
-    /// <param name="force" type="Boolean">Whether to delete the folder even if it has the read-only attribute set.</param>
-
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    fso.DeleteFolder(path, force);
-}
-
-function CopyFolder(source, dest, overwrite) {
-    /// <summary>Recursively copies a folder and its contents from source to dest.</summary>
-    /// <param name="source" type="String">Path to the source folder location.</param>
-    /// <param name="dest" type="String">Path to the destination folder location.</param>
-    /// <param name="overwrite" type="Boolean">Whether to overwrite a folder in the destination location.</param>
-
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    fso.CopyFolder(source, dest, overwrite);
-}
-
-
-function CopyFile(source, dest, overwrite) {
-    /// <summary>Copies a file from source to dest.</summary>
-    /// <param name="source" type="String">Path to the source file location.</param>
-    /// <param name="dest" type="String">Path to the destination file location.</param>
-    /// <param name="overwrite" type="Boolean">Whether to overwrite a file in the destination location.</param>
-
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-
-    if (overwrite && fso.FileExists(dest)) {
-        var f = fso.getFile(dest);
-        f.attributes = 0;
-    }
-
-    fso.CopyFile(source, dest, overwrite);
-}
-
-function ExtractContentsBetweenMarkers(path, contentOnly, isExclusion, startMarker, endMarker, callback) {
-    /// <summary>
-    /// Extracts the lines from the 'path' text file between the start and end markers.
-    /// </summary>
-    /// <param name="path" type="String">Path to file.</param>
-    /// <param name="contentOnly" type="Boolean">
-    /// true to skip everything until it's found between markers, false to start including everything from the start.
-    /// </param>
-    /// <param name="isExclusion" type="Boolean">
-    /// false if the 'extraction' means keeping the content; true if it means not excluding it from the result.
-    /// </param>
-    /// <param name="startMarker" type="String">Line content to match for content start.</param>
-    /// <param name="endMarker" type="String">Line content to match for content end.</param>
-    /// <param name="callback" type="Function" mayBeNull="true">
-    /// If true, then this function is called for every line along with the inContent flag
-    /// before the line is added; the called function may return a line
-    /// to be added in its place, null to skip processing.
-    /// </param>
-    /// <returns type="String">The string content of the file.</returns>
-
-    var content = ReadAllTextFile(path);
-    return ExtractContentsBetweenMarkersForText(content, contentOnly, isExclusion, startMarker, endMarker, callback);
-}
-
-function ExtractContentsBetweenMarkersForText(content, contentOnly, isExclusion, startMarker, endMarker, callback) {
-    /// <summary>
-    /// Extracts the lines from the specified text between the start and end markers.
-    /// </summary>
-    /// <param name="content" type="String">Text to process.</param>
-    /// <param name="contentOnly" type="Boolean">
-    /// true to skip everything until it's found between markers, false to start including everything from the start.
-    /// </param>
-    /// <param name="isExclusion" type="Boolean">
-    /// false if the 'extraction' means keeping the content; true if it means not excluding it from the result.
-    /// </param>
-    /// <param name="startMarker" type="String">Line content to match for content start.</param>
-    /// <param name="endMarker" type="String">Line content to match for content end.</param>
-    /// <param name="callback" type="Function" mayBeNull="true">
-    /// If true, then this function is called for every line along with the inContent flag
-    /// before the line is added; the called function may return a line
-    /// to be added in its place, null to skip processing.
-    /// </param>
-    /// <returns type="String">The extracted content.</returns>
-
-    var inContent = contentOnly === false;
-    var lines = StringSplit(content, "\r\n");
-    var result = [];
-    var i, len;
-    for (i = 0, len = lines.length; i < len; i++) {
-        var line = lines[i];
-        var contentStartIndex = line.indexOf(startMarker);
-        if (inContent === false && contentStartIndex !== -1) {
-            inContent = true;
-            continue;
-        }
-
-        var contentEndIndex = line.indexOf(endMarker);
-        if (inContent === true && contentEndIndex !== -1) {
-            inContent = false;
-            continue;
-        }
-
-        if (inContent !== isExclusion) {
-            if (callback) {
-                var callbackResult = callback(line, inContent);
-                if (callbackResult !== null && callbackResult !== undefined) {
-                    result.push(callbackResult);
-                }
-            } else {
-                result.push(line);
-            }
-        }
-    }
-
-    return result.join("\r\n");
-}
-
-function FolderExists(path) {
-    /// <summary>Checks whether the specified directory exists.</summary>
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    if (fso.FolderExists(path)) {
-        return true;
-    }
-    else {
-        return false;
-    }
-}
-
-function FileExists(path) {
-    /// <summary>Checks whether the specified file exists.</summary>
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    if (fso.FileExists(path)) {
-        return true;
-    }
-    else {
-        return false;
-    }
-}
-
-function GetEnvironmentVariable(name) {
-    /// <summary>Gets the value of the specified environment variable.</summary>
-    /// <param name="name" type="String">Name of the variable value to get.</param>
-    /// <returns type="String">Value for the given environment variable; null if undefined.</returns>
-    var shell = new ActiveXObject("WScript.Shell");
-    var result = shell.ExpandEnvironmentStrings("%" + name + "%");
-    if (result == "%" + name + "%") {
-        result = null;
-    }
-
-    return result;
-}
-
-function GetFilesRecursive(path) {
-    /// <summary>Gets all file names under the specified directory path.</summary>
-    /// <param name="path" type="String">Path to directory.</param>
-    /// <returns type="Array">Array of all file names under path.</returns>
-
-    var result = [];
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    var pending = [path];
-
-    while (pending.length) {
-        var item = pending.pop();
-        var folder = fso.GetFolder(item);
-        for (var files = new Enumerator(folder.Files); !files.atEnd(); files.moveNext()) {
-            result.push(files.item().Path);
-        }
-
-        for (var subFolders = new Enumerator(folder.SubFolders); !subFolders.atEnd(); subFolders.moveNext()) {
-            pending.push(subFolders.item().Path);
-        }
-    }
-
-    return result;
-}
-
-function GetRelativePathFrom(startPath, endPath) {
-    if (startPath[startPath.length - 1] !== "\\") {
-        startPath += "\\";
-    }
-
-    if (startPath.length > endPath.length) {
-        throw { message: "traversing up NYI" };
-    }
-
-    return endPath.substr(startPath.length);
-}
-
-function MatchesMask(file, mask) {
-    if (!mask) {
-        return false;
-    }
-
-    if (file === mask) {
-        return true;
-    }
-
-    if (mask.substr(0, 1) === "*") {
-        var rest = mask.substr(1);
-        return file.substr(file.length - rest.length) === rest;
-    } else if (mask.substr(mask.length - 1) === "*") {
-        var end = mask.substr(0, mask.length - 1);
-        return file.substr(0, end.length) === end;
-    }
-
-    return false;
-}
-
-function PathGetDirectory(path) {
-    /// <summary>
-    /// Returns the directory of the specified path string (excluding the trailing "\\");
-    /// empty if there is no path.
-    /// </summary>
-
-    var l = path.length;
-    var startIndex = l;
-    while (--startIndex >= 0) {
-        var ch = path.substr(startIndex, 1);
-        if (ch == "\\") {
-            if (startIndex === 0) {
-                return "";
-            } else {
-                return path.substr(0, startIndex);
-            }
-        }
-    }
-
-    return "";
-}
-
-function PathGetFileName(path) {
-    /// <summary>
-    /// Returns the file name for the specified path string; empty if there is no
-    /// directory information.
-    /// </summary>
-    var l = path.length;
-    var startIndex = l;
-    while (--startIndex >= 0) {
-        var ch = path.substr(startIndex, 1);
-        if (ch == "\\" || ch == "/" || ch == ":") {
-            return path.substr(startIndex, l - startIndex);
-        }
-    }
-    return "";
-}
-
-function PathGetExtension(path) {
-    /// <summary>
-    /// Returns the extension of the specified path string (including the ".");
-    /// empty if there is no extension.
-    /// </summary>
-    var l = path.length;
-    var startIndex = l;
-    while (--startIndex >= 0) {
-        var ch = path.substr(startIndex, 1);
-        if (ch == ".") {
-            if (startIndex != (l - 1)) {
-                return path.substr(startIndex, l - startIndex);
-            }
-            return "";
-        }
-        else if (ch == "\\" || ch == ":") {
-            break;
-        }
-    }
-    return "";
-}
-
-function ReadAllTextFile(path) {
-    /// <summary>Reads all the content of the file into a string.</summary>
-    /// <param name="path" type="String">File name to read from.</param>
-    /// <returns type="String">File contents.</returns>
-    var ForReading = 1, ForWriting = 2;
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    var file = fso.OpenTextFile(path, ForReading);
-    try {
-        var result;
-        if (file.AtEndOfStream) {
-            result = "";
-        } else {
-            result = file.ReadAll();
-        }
-    } finally {
-        file.Close();
-    }
-
-    return result;
-}
-
-function ReadXmlFile(path) {
-    /// <summary>Reads an XML document from the specified path.</summary>
-    /// <param name="path" type="String">Path to file on disk.</param>
-    /// <returns>A DOMDocument with the contents of the given file.</returns>
-    var result = new ActiveXObject("Msxml2.DOMDocument.6.0");
-    result.async = false;
-    result.load(path);
-    if (result.parseError.errorCode !== 0) {
-        throw { message: "Error reading '" + path + "': " + result.parseError.reason };
-    }
-
-    return result;
-}
-
-// Runs the specified function catching exceptions and quits the current script.
-function RunAndQuit(f) {
-    try {
-        f();
-    }
-    catch (e) {
-        // An error with 'statusCode' defined will avoid the usual error dump handling.
-        if (e.statusCode !== undefined) {
-            if (e.message) {
-                WScript.Echo(e.message);
-            }
-
-            WScript.Quit(e.statusCode);
-        }
-
-        WScript.Echo("Error caught while running this function:");
-        WScript.Echo(f.toString());
-        WScript.Echo("Error details:");
-        if (typeof (e) == "object" && e.toString() == "[object Object]" || e.toString() === "[object Error]") {
-            for (var p in e) WScript.Echo(" " + p + ": " + e[p]);
-        }
-        else {
-            WScript.Echo(e);
-        }
-
-        WScript.Quit(1);
-    }
-    WScript.Quit(0);
-}
-
-function RunConsoleCommand(strCommand, timeout, retry) {
-    /// <summary>Runs a command and waits for it to exit.</summary>
-    /// <param name="strCommand" type="String">Command to run.</param>
-    /// <param name="timeout" type="int">Timeout in seconds.</param>
-    /// <param name="timeout" type="bool">Boolean specifying whether to retry on timeout or not.</param>
-    /// <returns type="Array">An array with stdout in 0, stderr in 1 and exit code in 2. Forced
-    /// termination sets 2 to 1.</returns>
-    var WshShell = new ActiveXObject("WScript.Shell");
-    var result = new Array(3);
-    var oExec = WshShell.Exec(strCommand);
-    var counter = 0;
-
-    if (timeout) {
-        // Status of 0 means the process is still running
-        while (oExec.Status === 0 && counter < timeout) {
-            WScript.Sleep(1000);
-            counter++;
-        }
-
-        if (timeout === counter && oExec.Status === 0) {
-            WScript.Echo("Forcefully terminating " + strCommand + " after " + timeout + " seconds.");
-            oExec.Terminate();
-            result[2] = 1;
-            if (retry) {
-                return RunConsoleCommand(strCommand, timeout, false);
-            }
-        }
-    }
-
-    result[0] = oExec.StdOut.ReadAll();
-    result[1] = oExec.StdErr.ReadAll();
-
-    if (!result[2]) {
-        result[2] = oExec.ExitCode;
-    }
-
-    return result;
-}
-
-function SaveTextToFile(content, path) {
-    /// <summary>Saves text content into a file.</summary>
-    /// <param name="content" type="String">Content to save.</param>
-    /// <param name="path" type="String">Path of file to save into.</param>
-    var ForReading = 1, ForWriting = 2;
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    var file = fso.OpenTextFile(path, ForWriting, true);
-    file.Write(content);
-    file.Close();
-}
-
-function StringSplit(strLine, strSeparator) {
-    /// <summary>Splits a string into a string array.</summary>
-    var result = new Array();
-    var startIndex = 0;
-    var resultIndex = 0;
-    while (startIndex < strLine.length) {
-        var endIndex = strLine.indexOf(strSeparator, startIndex);
-        if (endIndex == -1) {
-            endIndex = strLine.length;
-        }
-        result[resultIndex] = strLine.substring(startIndex, endIndex);
-        startIndex = endIndex + strSeparator.length;
-        resultIndex++;
-    }
-    return result;
-}
-
-function PathCombine(path1, path2) {
-    if (path1.charAt(path1.length - 1) !== "\\") {
-        return path1 + "\\" + path2;
-    }
-    return path1 + path2;
-}
-
-function RemoveReadOnlyAttribute(path) {
-    /// <summary>Removes the read-only attribute on the specified file.</summary>
-    /// <param name="path" type="String">Path to the file.</param>
-    var fso = new ActiveXObject("Scripting.FileSystemObject");
-    var f = fso.getFile(path);
-    if (1 === (f.attributes & 1)) {
-        f.attributes = (f.attributes & ~1);
-    }
-}
-
-function WriteXmlFile(document, path) {
-    /// <summary>Write an XML document to the specified path.</summary>
-    /// <param name="path" type="String">Path to file on disk.</param>
-    document.save(path);
+// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
+// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+//
+// References:
+//
+// JScript Language Reference
+// http://msdn2.microsoft.com/en-us/library/yek4tbz0
+//
+// Windows Script Host Object Model
+// http://msdn2.microsoft.com/en-us/library/a74hyyw0
+//
+// Script Runtime
+// http://msdn2.microsoft.com/en-us/library/hww8txat.aspx
+//
+
+function ArrayAny(arr, callback) {
+    /// <summary>Checks whether any element in an array satisfies a predicate.</summary>
+    /// <param name="arr" type="Array">Array to operate on.</param>
+    /// <param name="callback" type="Function">Function to test with element and index, returning true or false.</param>
+    /// <returns type="Boolean">true if 'callback' returns true for any element; false otherwise.</returns>
+    for (var i = 0; i < arr.length; i++) {
+        if (callback(arr[i], i)) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+function ArrayWhere(arr, callback) {
+    /// <summary>Returns the elements in an array that satisfy a predicate.</summary>
+    /// <param name="arr" type="Array">Array to operate on.</param>
+    /// <param name="callback" type="Function">Function to test with element and index, returning true or false.</param>
+    /// <returns type="Array">Array of elements from arr that satisfy the predicate.</returns>
+
+    var result = [];
+
+    for (var i = 0; i < arr.length; i++) {
+        if (callback(arr[i], i)) {
+            result.push(arr[i]);
+        }
+    }
+    return result;
+}
+
+function ArrayForEach(arr, callback) {
+    /// <summary>Invokes a callback for each element in the array.</summary>
+    /// <param name="arr" type="Array">Array to operate on.</param>
+    /// <param name="callback" type="Function">Function to invoke with element and index.</param>
+    for (var i = 0; i < arr.length; i++) {
+        callback(arr[i], i);
+    }
+}
+
+function CheckScriptFlag(name) {
+    /// <summary>Checks whether a script argument was given with true or false.</summary>
+    /// <param name="name" type="String">Argument name to check.</param>
+    /// <returns type="Boolean">
+    /// true if the argument was given witha value of 'true' or 'True'; false otherwise.
+    /// </returns>
+    var flag = WScript.Arguments.Named(name);
+    if (!flag) {
+        return false;
+    }
+
+    return flag === "true" || flag === "True";
+}
+
+function CreateFolderIfMissing(path) {
+    /// <summary>Creates a folder if it doesn't exist.</summary>
+    /// <param name="path" type="String">Path to folder to create.</param>
+    /// <remarks>This function will write out to the console on creation.</remarks>
+    if (!path) return;
+    var parent = PathGetDirectory(path);
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    if (!fso.FolderExists(parent)) {
+        CreateFolderIfMissing(parent);
+    }
+    if (!fso.FolderExists(path)) {
+        WScript.Echo("Creating " + path + "...");
+        fso.CreateFolder(path);
+    }
+}
+
+function DeleteFile(path, force) {
+    /// <summary>Deletes a file.</summary>
+    /// <param name="path" type="String">Path to the file.</param>
+    /// <param name="force" type="Boolean">Whether to delete the file even if it has the read-only attribute set.</param>
+
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    fso.DeleteFile(path, force);
+}
+
+function DeleteFolder(path, force) {
+    /// <summary>Deletes a folder.</summary>
+    /// <param name="path" type="String">Path to the folder.</param>
+    /// <param name="force" type="Boolean">Whether to delete the folder even if it has the read-only attribute set.</param>
+
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    fso.DeleteFolder(path, force);
+}
+
+function CopyFolder(source, dest, overwrite) {
+    /// <summary>Recursively copies a folder and its contents from source to dest.</summary>
+    /// <param name="source" type="String">Path to the source folder location.</param>
+    /// <param name="dest" type="String">Path to the destination folder location.</param>
+    /// <param name="overwrite" type="Boolean">Whether to overwrite a folder in the destination location.</param>
+
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    fso.CopyFolder(source, dest, overwrite);
+}
+
+
+function CopyFile(source, dest, overwrite) {
+    /// <summary>Copies a file from source to dest.</summary>
+    /// <param name="source" type="String">Path to the source file location.</param>
+    /// <param name="dest" type="String">Path to the destination file location.</param>
+    /// <param name="overwrite" type="Boolean">Whether to overwrite a file in the destination location.</param>
+
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+
+    if (overwrite && fso.FileExists(dest)) {
+        var f = fso.getFile(dest);
+        f.attributes = 0;
+    }
+
+    fso.CopyFile(source, dest, overwrite);
+}
+
+function ExtractContentsBetweenMarkers(path, contentOnly, isExclusion, startMarker, endMarker, callback) {
+    /// <summary>
+    /// Extracts the lines from the 'path' text file between the start and end markers.
+    /// </summary>
+    /// <param name="path" type="String">Path to file.</param>
+    /// <param name="contentOnly" type="Boolean">
+    /// true to skip everything until it's found between markers, false to start including everything from the start.
+    /// </param>
+    /// <param name="isExclusion" type="Boolean">
+    /// false if the 'extraction' means keeping the content; true if it means not excluding it from the result.
+    /// </param>
+    /// <param name="startMarker" type="String">Line content to match for content start.</param>
+    /// <param name="endMarker" type="String">Line content to match for content end.</param>
+    /// <param name="callback" type="Function" mayBeNull="true">
+    /// If true, then this function is called for every line along with the inContent flag
+    /// before the line is added; the called function may return a line
+    /// to be added in its place, null to skip processing.
+    /// </param>
+    /// <returns type="String">The string content of the file.</returns>
+
+    var content = ReadAllTextFile(path);
+    return ExtractContentsBetweenMarkersForText(content, contentOnly, isExclusion, startMarker, endMarker, callback);
+}
+
+function ExtractContentsBetweenMarkersForText(content, contentOnly, isExclusion, startMarker, endMarker, callback) {
+    /// <summary>
+    /// Extracts the lines from the specified text between the start and end markers.
+    /// </summary>
+    /// <param name="content" type="String">Text to process.</param>
+    /// <param name="contentOnly" type="Boolean">
+    /// true to skip everything until it's found between markers, false to start including everything from the start.
+    /// </param>
+    /// <param name="isExclusion" type="Boolean">
+    /// false if the 'extraction' means keeping the content; true if it means not excluding it from the result.
+    /// </param>
+    /// <param name="startMarker" type="String">Line content to match for content start.</param>
+    /// <param name="endMarker" type="String">Line content to match for content end.</param>
+    /// <param name="callback" type="Function" mayBeNull="true">
+    /// If true, then this function is called for every line along with the inContent flag
+    /// before the line is added; the called function may return a line
+    /// to be added in its place, null to skip processing.
+    /// </param>
+    /// <returns type="String">The extracted content.</returns>
+
+    var inContent = contentOnly === false;
+    var lines = StringSplit(content, "\r\n");
+    var result = [];
+    var i, len;
+    for (i = 0, len = lines.length; i < len; i++) {
+        var line = lines[i];
+        var contentStartIndex = line.indexOf(startMarker);
+        if (inContent === false && contentStartIndex !== -1) {
+            inContent = true;
+            continue;
+        }
+
+        var contentEndIndex = line.indexOf(endMarker);
+        if (inContent === true && contentEndIndex !== -1) {
+            inContent = false;
+            continue;
+        }
+
+        if (inContent !== isExclusion) {
+            if (callback) {
+                var callbackResult = callback(line, inContent);
+                if (callbackResult !== null && callbackResult !== undefined) {
+                    result.push(callbackResult);
+                }
+            } else {
+                result.push(line);
+            }
+        }
+    }
+
+    return result.join("\r\n");
+}
+
+function FolderExists(path) {
+    /// <summary>Checks whether the specified directory exists.</summary>
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    if (fso.FolderExists(path)) {
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+function FileExists(path) {
+    /// <summary>Checks whether the specified file exists.</summary>
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    if (fso.FileExists(path)) {
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+function GetEnvironmentVariable(name) {
+    /// <summary>Gets the value of the specified environment variable.</summary>
+    /// <param name="name" type="String">Name of the variable value to get.</param>
+    /// <returns type="String">Value for the given environment variable; null if undefined.</returns>
+    var shell = new ActiveXObject("WScript.Shell");
+    var result = shell.ExpandEnvironmentStrings("%" + name + "%");
+    if (result == "%" + name + "%") {
+        result = null;
+    }
+
+    return result;
+}
+
+function GetFilesRecursive(path) {
+    /// <summary>Gets all file names under the specified directory path.</summary>
+    /// <param name="path" type="String">Path to directory.</param>
+    /// <returns type="Array">Array of all file names under path.</returns>
+
+    var result = [];
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    var pending = [path];
+
+    while (pending.length) {
+        var item = pending.pop();
+        var folder = fso.GetFolder(item);
+        for (var files = new Enumerator(folder.Files); !files.atEnd(); files.moveNext()) {
+            result.push(files.item().Path);
+        }
+
+        for (var subFolders = new Enumerator(folder.SubFolders); !subFolders.atEnd(); subFolders.moveNext()) {
+            pending.push(subFolders.item().Path);
+        }
+    }
+
+    return result;
+}
+
+function GetRelativePathFrom(startPath, endPath) {
+    if (startPath[startPath.length - 1] !== "\\") {
+        startPath += "\\";
+    }
+
+    if (startPath.length > endPath.length) {
+        throw { message: "traversing up NYI" };
+    }
+
+    return endPath.substr(startPath.length);
+}
+
+function MatchesMask(file, mask) {
+    if (!mask) {
+        return false;
+    }
+
+    if (file === mask) {
+        return true;
+    }
+
+    if (mask.substr(0, 1) === "*") {
+        var rest = mask.substr(1);
+        return file.substr(file.length - rest.length) === rest;
+    } else if (mask.substr(mask.length - 1) === "*") {
+        var end = mask.substr(0, mask.length - 1);
+        return file.substr(0, end.length) === end;
+    }
+
+    return false;
+}
+
+function PathGetDirectory(path) {
+    /// <summary>
+    /// Returns the directory of the specified path string (excluding the trailing "\\");
+    /// empty if there is no path.
+    /// </summary>
+
+    var l = path.length;
+    var startIndex = l;
+    while (--startIndex >= 0) {
+        var ch = path.substr(startIndex, 1);
+        if (ch == "\\") {
+            if (startIndex === 0) {
+                return "";
+            } else {
+                return path.substr(0, startIndex);
+            }
+        }
+    }
+
+    return "";
+}
+
+function PathGetFileName(path) {
+    /// <summary>
+    /// Returns the file name for the specified path string; empty if there is no
+    /// directory information.
+    /// </summary>
+    var l = path.length;
+    var startIndex = l;
+    while (--startIndex >= 0) {
+        var ch = path.substr(startIndex, 1);
+        if (ch == "\\" || ch == "/" || ch == ":") {
+            return path.substr(startIndex, l - startIndex);
+        }
+    }
+    return "";
+}
+
+function PathGetExtension(path) {
+    /// <summary>
+    /// Returns the extension of the specified path string (including the ".");
+    /// empty if there is no extension.
+    /// </summary>
+    var l = path.length;
+    var startIndex = l;
+    while (--startIndex >= 0) {
+        var ch = path.substr(startIndex, 1);
+        if (ch == ".") {
+            if (startIndex != (l - 1)) {
+                return path.substr(startIndex, l - startIndex);
+            }
+            return "";
+        }
+        else if (ch == "\\" || ch == ":") {
+            break;
+        }
+    }
+    return "";
+}
+
+function ReadAllTextFile(path) {
+    /// <summary>Reads all the content of the file into a string.</summary>
+    /// <param name="path" type="String">File name to read from.</param>
+    /// <returns type="String">File contents.</returns>
+    var ForReading = 1, ForWriting = 2;
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    var file = fso.OpenTextFile(path, ForReading);
+    try {
+        var result;
+        if (file.AtEndOfStream) {
+            result = "";
+        } else {
+            result = file.ReadAll();
+        }
+    } finally {
+        file.Close();
+    }
+
+    return result;
+}
+
+function ReadXmlFile(path) {
+    /// <summary>Reads an XML document from the specified path.</summary>
+    /// <param name="path" type="String">Path to file on disk.</param>
+    /// <returns>A DOMDocument with the contents of the given file.</returns>
+    var result = new ActiveXObject("Msxml2.DOMDocument.6.0");
+    result.async = false;
+    result.load(path);
+    if (result.parseError.errorCode !== 0) {
+        throw { message: "Error reading '" + path + "': " + result.parseError.reason };
+    }
+
+    return result;
+}
+
+// Runs the specified function catching exceptions and quits the current script.
+function RunAndQuit(f) {
+    try {
+        f();
+    }
+    catch (e) {
+        // An error with 'statusCode' defined will avoid the usual error dump handling.
+        if (e.statusCode !== undefined) {
+            if (e.message) {
+                WScript.Echo(e.message);
+            }
+
+            WScript.Quit(e.statusCode);
+        }
+
+        WScript.Echo("Error caught while running this function:");
+        WScript.Echo(f.toString());
+        WScript.Echo("Error details:");
+        if (typeof (e) == "object" && e.toString() == "[object Object]" || e.toString() === "[object Error]") {
+            for (var p in e) WScript.Echo(" " + p + ": " + e[p]);
+        }
+        else {
+            WScript.Echo(e);
+        }
+
+        WScript.Quit(1);
+    }
+    WScript.Quit(0);
+}
+
+function RunConsoleCommand(strCommand, timeout, retry) {
+    /// <summary>Runs a command and waits for it to exit.</summary>
+    /// <param name="strCommand" type="String">Command to run.</param>
+    /// <param name="timeout" type="int">Timeout in seconds.</param>
+    /// <param name="timeout" type="bool">Boolean specifying whether to retry on timeout or not.</param>
+    /// <returns type="Array">An array with stdout in 0, stderr in 1 and exit code in 2. Forced
+    /// termination sets 2 to 1.</returns>
+    var WshShell = new ActiveXObject("WScript.Shell");
+    var result = new Array(3);
+    var oExec = WshShell.Exec(strCommand);
+    var counter = 0;
+
+    if (timeout) {
+        // Status of 0 means the process is still running
+        while (oExec.Status === 0 && counter < timeout) {
+            WScript.Sleep(1000);
+            counter++;
+        }
+
+        if (timeout === counter && oExec.Status === 0) {
+            WScript.Echo("Forcefully terminating " + strCommand + " after " + timeout + " seconds.");
+            oExec.Terminate();
+            result[2] = 1;
+            if (retry) {
+                return RunConsoleCommand(strCommand, timeout, false);
+            }
+        }
+    }
+
+    result[0] = oExec.StdOut.ReadAll();
+    result[1] = oExec.StdErr.ReadAll();
+
+    if (!result[2]) {
+        result[2] = oExec.ExitCode;
+    }
+
+    return result;
+}
+
+function SaveTextToFile(content, path) {
+    /// <summary>Saves text content into a file.</summary>
+    /// <param name="content" type="String">Content to save.</param>
+    /// <param name="path" type="String">Path of file to save into.</param>
+    var ForReading = 1, ForWriting = 2;
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    var file = fso.OpenTextFile(path, ForWriting, true);
+    file.Write(content);
+    file.Close();
+}
+
+function StringSplit(strLine, strSeparator) {
+    /// <summary>Splits a string into a string array.</summary>
+    var result = new Array();
+    var startIndex = 0;
+    var resultIndex = 0;
+    while (startIndex < strLine.length) {
+        var endIndex = strLine.indexOf(strSeparator, startIndex);
+        if (endIndex == -1) {
+            endIndex = strLine.length;
+        }
+        result[resultIndex] = strLine.substring(startIndex, endIndex);
+        startIndex = endIndex + strSeparator.length;
+        resultIndex++;
+    }
+    return result;
+}
+
+function PathCombine(path1, path2) {
+    if (path1.charAt(path1.length - 1) !== "\\") {
+        return path1 + "\\" + path2;
+    }
+    return path1 + path2;
+}
+
+function RemoveReadOnlyAttribute(path) {
+    /// <summary>Removes the read-only attribute on the specified file.</summary>
+    /// <param name="path" type="String">Path to the file.</param>
+    var fso = new ActiveXObject("Scripting.FileSystemObject");
+    var f = fso.getFile(path);
+    if (1 === (f.attributes & 1)) {
+        f.attributes = (f.attributes & ~1);
+    }
+}
+
+function WriteXmlFile(document, path) {
+    /// <summary>Write an XML document to the specified path.</summary>
+    /// <param name="path" type="String">Path to file on disk.</param>
+    document.save(path);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djslicense.js
----------------------------------------------------------------------
diff --git a/BuildTools/djslicense.js b/BuildTools/djslicense.js
index a6bfe15..7cd3a35 100644
--- a/BuildTools/djslicense.js
+++ b/BuildTools/djslicense.js
@@ -1,12 +1,12 @@
-// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
+// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djspatchtests.js
----------------------------------------------------------------------
diff --git a/BuildTools/djspatchtests.js b/BuildTools/djspatchtests.js
index ef977f6..80036f7 100644
--- a/BuildTools/djspatchtests.js
+++ b/BuildTools/djspatchtests.js
@@ -1,55 +1,55 @@
-/// <reference path="djscommon.js" />
-
-// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// This script will search for a particular text pattern in an html file and replace its first occurrence with the value defined in 
-// the replace-script parameter. All other lines with subsequent occurrences of the pattern will be removed from the file. 
-
-function Main() {
-    var shell = new ActiveXObject("WScript.Shell");
-    var inputPath = shell.ExpandEnvironmentStrings(WScript.Arguments.Named("in"));
-    var replaceScript = WScript.Arguments.Named("replace-script");
-    var removePattern = /\.\.\/src\/.*\.js/;
-
-    var files = ArrayWhere(GetFilesRecursive(inputPath), function (file) {
-        return MatchesMask(file, "*.htm") || MatchesMask(file, "*.html");
-    });
-
-    ArrayForEach(files, function (file) {
-        var content = ReadAllTextFile(file);
-        var lines = StringSplit(content, "\r\n");
-        var result = [];
-        var included = false;
-        ArrayForEach(lines, function (line) {
-            if (line.match(removePattern)) {
-                if (!included) {
-                    included = true;
-                    line = line.replace(removePattern, replaceScript);
-                    result.push(line);
-                }
-            } else {
-                result.push(line);
-            }
-        });
-
-        if (included) {
-            content = result.join("\r\n");
-            WScript.Echo("Patched " + file);
-            RemoveReadOnlyAttribute(file);
-            SaveTextToFile(content, file);
-        }
-    });
-}
-
+/// <reference path="djscommon.js" />
+
+// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
+// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// This script will search for a particular text pattern in an html file and replace its first occurrence with the value defined in 
+// the replace-script parameter. All other lines with subsequent occurrences of the pattern will be removed from the file. 
+
+function Main() {
+    var shell = new ActiveXObject("WScript.Shell");
+    var inputPath = shell.ExpandEnvironmentStrings(WScript.Arguments.Named("in"));
+    var replaceScript = WScript.Arguments.Named("replace-script");
+    var removePattern = /\.\.\/src\/.*\.js/;
+
+    var files = ArrayWhere(GetFilesRecursive(inputPath), function (file) {
+        return MatchesMask(file, "*.htm") || MatchesMask(file, "*.html");
+    });
+
+    ArrayForEach(files, function (file) {
+        var content = ReadAllTextFile(file);
+        var lines = StringSplit(content, "\r\n");
+        var result = [];
+        var included = false;
+        ArrayForEach(lines, function (line) {
+            if (line.match(removePattern)) {
+                if (!included) {
+                    included = true;
+                    line = line.replace(removePattern, replaceScript);
+                    result.push(line);
+                }
+            } else {
+                result.push(line);
+            }
+        });
+
+        if (included) {
+            content = result.join("\r\n");
+            WScript.Echo("Patched " + file);
+            RemoveReadOnlyAttribute(file);
+            SaveTextToFile(content, file);
+        }
+    });
+}
+
 RunAndQuit(Main);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/e387fc92/BuildTools/djspatchtests.wsf
----------------------------------------------------------------------
diff --git a/BuildTools/djspatchtests.wsf b/BuildTools/djspatchtests.wsf
index 7df918a..4d073fb 100644
--- a/BuildTools/djspatchtests.wsf
+++ b/BuildTools/djspatchtests.wsf
@@ -1,14 +1,14 @@
-<package>
-  <job>
-    <runtime>
-      <description>
-      This script is used to patch the html files so they can use the build output.
-      </description>
-      <named name="in" helpstring="Path to directory with the html test files to patch." type="string" required="true" />
-      <named name="replace-script" helpstring="Target script reference." type="string" required="true" />
-      <example>cscript djspatchtests.wsf //Nologo /in:%DJSOUT%\jslib.sln\tests /replace-script:"../src/datajs-%DJSVER%.js"</example>
-    </runtime>
-    <script language="JScript" src="djscommon.js" />
-    <script language="JScript" src="djspatchtests.js" />
-  </job>
+<package>
+  <job>
+    <runtime>
+      <description>
+      This script is used to patch the html files so they can use the build output.
+      </description>
+      <named name="in" helpstring="Path to directory with the html test files to patch." type="string" required="true" />
+      <named name="replace-script" helpstring="Target script reference." type="string" required="true" />
+      <example>cscript djspatchtests.wsf //Nologo /in:%DJSOUT%\jslib.sln\tests /replace-script:"../src/datajs-%DJSVER%.js"</example>
+    </runtime>
+    <script language="JScript" src="djscommon.js" />
+    <script language="JScript" src="djspatchtests.js" />
+  </job>
 </package>
\ No newline at end of file