Skip to content

Instantly share code, notes, and snippets.

@sgrebnov
Last active August 29, 2015 14:02
Show Gist options
  • Save sgrebnov/e947712eb441b5084d49 to your computer and use it in GitHub Desktop.
Save sgrebnov/e947712eb441b5084d49 to your computer and use it in GitHub Desktop.
Visual Studio for MDA development - enable console output for Windows Phone 8

Currently Windows Phone 8 deploy command (deploy.js) is blocking + it uses ReadAll insteadof while loop and ReadLine. Due to this there is no way to see real time output from the app in Visual Studio output window.

Instructions below could be used to fix this.

  1. Find the following file (should be created after you build Windows Phone platform at least once) YouCordovaApp\bld\Debug\platforms\wp8\cordova\lib\deploy.js
  2. Fine function exec_verbose(command) command inside it
  // executes a commmand in the shell
  function exec_verbose(command) {
      //Log("Command: " + command);
      var oShell=wscript_shell.Exec(command);
      while (oShell.Status == 0) {
          //Wait a little bit so we're not super looping
          WScript.sleep(100);
          //Print any stdout output from the script
          if (!oShell.StdOut.AtEndOfStream) {
              var line = oShell.StdOut.ReadAll();
              Log(line);
          }
      }
      //Check to make sure our scripts did not encounter an error
      if (!oShell.StdErr.AtEndOfStream) {
          var line = oShell.StdErr.ReadAll();
          Log("ERROR: command failed in deploy.js : " + command);
          Log(line, true);
          WScript.Quit(2);
      }
  }
  1. Replace original version with the following one. It replaces ReadAll with while loop and ReadLine
  // executes a commmand in the shell
  function exec_verbose(command) {
      //Log("Command: " + command);
      var oShell=wscript_shell.Exec(command);
      while (oShell.Status == 0) {
          //Wait a little bit so we're not super looping
          WScript.sleep(100);
          //Print any stdout output from the script
          while (!oShell.StdOut.AtEndOfStream) {
              var line = oShell.StdOut.ReadLine();
              Log(line);
          }
  
      }
      //Check to make sure our scripts did not encounter an error
      if (!oShell.StdErr.AtEndOfStream) {
          var line = oShell.StdErr.ReadAll();
          Log("ERROR: command failed in deploy.js : " + command);
          Log(line, true);
          WScript.Quit(2);
      }
  }

You are done, you should now see console.log messages in your Visual Studio output window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment