You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/05/17 09:21:40 UTC
[1/2] wp7 commit: added usage, and parameterized device to deploy to
Updated Branches:
refs/heads/master 4251cf3e2 -> 74eeb59a2
added usage, and parameterized device to deploy to
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/74eeb59a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/74eeb59a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/74eeb59a
Branch: refs/heads/master
Commit: 74eeb59a280c4e89e43d85d45e5b0403e6ca8e9a
Parents: 9d38ecf
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 17 00:16:50 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 17 00:16:50 2012 -0700
----------------------------------------------------------------------
tooling/CordovaDeploy/CordovaDeploy/Program.cs | 98 +++++++++++--------
1 files changed, 55 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/74eeb59a/tooling/CordovaDeploy/CordovaDeploy/Program.cs
----------------------------------------------------------------------
diff --git a/tooling/CordovaDeploy/CordovaDeploy/Program.cs b/tooling/CordovaDeploy/CordovaDeploy/Program.cs
index 003509d..a3ae2c0 100644
--- a/tooling/CordovaDeploy/CordovaDeploy/Program.cs
+++ b/tooling/CordovaDeploy/CordovaDeploy/Program.cs
@@ -10,37 +10,36 @@ using System.Xml.XPath;
using System.Xml;
using System.Xml.Linq;
+
namespace CordovaDeploy
{
- class Program
+
+ class DeployTool
{
- static void Log(string msg)
+ static void Usage()
{
- Debug.WriteLine(msg);
- Console.Error.WriteLine(msg);
+ Log("Usage: CordovaDeploy [ -devices BuildOutputPath -d:DeviceIndex ]");
+ Log(" -devices : lists the devices and exits");
+ Log(" BuildOutputPath : path to the built application, typically Bin/Debug/ or Bin/Release/");
+ Log(" -d : index of the device to deploy, default is 0 ");
+ Log("examples:");
+ Log(" CordovaDeploy -devices");
+ Log(" CordovaDeploy Bin/Debug");
+ Log(" CordovaDeploy Bin/Release -d:1");
+
}
- static void Usage()
+ static void ReadWait()
{
- Log("Usage:");
+ //Console.WriteLine("\nPress ENTER to continue...");
+ //Console.Read();
}
-
-
- static void ListDevices()
+ static void Log(string msg)
{
- // Get CoreCon WP7 SDK
- DatastoreManager dsmgrObj = new DatastoreManager(1033);
- Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
- Collection<Device> devices = WP7SDK.GetDevices();
- for (int index = 0; index < devices.Count; index++)
- {
- Device d = devices[index];
- string info = string.Format("{0} : {1} : {2}", index.ToString(), d.Id, d.Name);
- Log(info);
- }
-
+ Debug.WriteLine(msg);
+ Console.Error.WriteLine(msg);
}
static Guid ReadAppId(string root)
@@ -71,8 +70,26 @@ namespace CordovaDeploy
return appID;
}
+
+
+ static void ListDevices()
+ {
+ // Get CoreCon WP7 SDK
+ DatastoreManager dsmgrObj = new DatastoreManager(1033);
+ Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
+ Collection<Device> devices = WP7SDK.GetDevices();
+ for (int index = 0; index < devices.Count; index++)
+ {
+ Device d = devices[index];
+ string info = string.Format("{0} : {1} : {2}", index.ToString(), d.Id, d.Name);
+ Log(info);
+ }
+ }
+
static void Main(string[] args)
{
+ int deviceIndex = 0;
+
string iconFilePath = "";
string xapFilePath = "";
Guid appID = Guid.Empty;
@@ -82,6 +99,7 @@ namespace CordovaDeploy
if (args.Length < 1)
{
Usage();
+ ReadWait();
return;
}
else if (args[0] == "-devices")
@@ -89,18 +107,22 @@ namespace CordovaDeploy
ListDevices();
return;
}
+ else if (args[1].StartsWith("-d:"))
+ {
+ deviceIndex = int.Parse(args[1].Substring(3));
+ }
+
if (Directory.Exists(args[0]))
{
DirectoryInfo info = new DirectoryInfo(args[0]);
- Debug.WriteLine("expanded path is : " + info.FullName);
root = info.FullName;
}
appID = ReadAppId(root);
-
if (appID == Guid.Empty)
{
+ // Logging of errors is done in ReadAppId
return;
}
@@ -111,6 +133,7 @@ namespace CordovaDeploy
else
{
Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"));
+ ReadWait();
return;
}
@@ -119,14 +142,14 @@ namespace CordovaDeploy
if (string.IsNullOrEmpty(xapFilePath))
{
Log(string.Format("Error: could not find application .xap in folder {0}", root));
+ ReadWait();
return;
}
// Get CoreCon WP7 SDK
DatastoreManager dsmgrObj = new DatastoreManager(1033);
- Collection<Platform> WP7SDKs = dsmgrObj.GetPlatforms();//.Single(p => p.Name == "New Windows Mobile 7 SDK");
-
+ Collection<Platform> WP7SDKs = dsmgrObj.GetPlatforms();
Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
Collection<Device> devices = null;
@@ -134,13 +157,7 @@ namespace CordovaDeploy
devices = WP7SDK.GetDevices();
//// Get Emulator / Device
- bool useEmulator = false;
- Device WP7Device = null;
-
- if (useEmulator)
- WP7Device = WP7SDK.GetDevices().Single(d => d.Name == "Windows Phone Emulator - 512 MB"); // || 256 ...
- else
- WP7Device = WP7SDK.GetDevices().Single(d => d.Name == "Windows Phone Device");
+ Device WP7Device = devices[deviceIndex];
if (WP7Device != null)
{
@@ -157,31 +174,26 @@ namespace CordovaDeploy
}
catch (Exception ex)
{
- Console.WriteLine(ex.Message);
+ Console.WriteLine("Error: " + ex.Message);
+ ReadWait();
return;
}
}
- if (args.Contains("-r") && WP7Device.IsApplicationInstalled(appID))
+ if (WP7Device.IsApplicationInstalled(appID))
{
- Log("Uninstalling sample XAP to Windows Phone 7 Emulator/Device...");
-
+ Log("Uninstalling XAP from " + WP7Device.Name);
app = WP7Device.GetApplication(appID);
app.Uninstall();
-
- Log("Sample XAP Uninstalled from Windows Phone 7 Emulator/Device...");
}
+ Log("Installing app on " + WP7Device.Name);
app = WP7Device.InstallApplication(appID, appID, "NormalApp", iconFilePath, xapFilePath);
- Log("XAP installed to Windows Phone 7 Emulator...");
-
- // Launch Application
- Log("Launching app on Windows Phone 7 Emulator...");
+ Log("Launching app on " + WP7Device.Name);
app.Launch();
- Log("Launched app on Windows Phone 7 Emulator..." + app.InstanceID.ToString());
-
+ ReadWait();
}
}
}