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/14 21:46:30 UTC
wp7 commit: added deploy tool to install and launch on device WIP
Updated Branches:
refs/heads/master fb9d7b41a -> 00955c48f
added deploy tool to install and launch on device WIP
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/00955c48
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/00955c48
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/00955c48
Branch: refs/heads/master
Commit: 00955c48f3f2ee2a05ef480d9f5870c1ca689bba
Parents: fb9d7b4
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon May 14 12:45:42 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon May 14 12:45:42 2012 -0700
----------------------------------------------------------------------
tooling/CordovaDeploy/CordovaDeploy.sln | 20 ++
.../CordovaDeploy/CordovaDeploy.csproj | 61 +++++
tooling/CordovaDeploy/CordovaDeploy/Program.cs | 188 +++++++++++++++
.../CordovaDeploy/Properties/AssemblyInfo.cs | 36 +++
4 files changed, 305 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/00955c48/tooling/CordovaDeploy/CordovaDeploy.sln
----------------------------------------------------------------------
diff --git a/tooling/CordovaDeploy/CordovaDeploy.sln b/tooling/CordovaDeploy/CordovaDeploy.sln
new file mode 100644
index 0000000..3305276
--- /dev/null
+++ b/tooling/CordovaDeploy/CordovaDeploy.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CordovaDeploy", "CordovaDeploy\CordovaDeploy.csproj", "{E752165B-AF59-4FF0-8601-A2A69FE09E0E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Debug|x86.ActiveCfg = Debug|x86
+ {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Debug|x86.Build.0 = Debug|x86
+ {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Release|x86.ActiveCfg = Release|x86
+ {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/00955c48/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
----------------------------------------------------------------------
diff --git a/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj b/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
new file mode 100644
index 0000000..b4e487a
--- /dev/null
+++ b/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E752165B-AF59-4FF0-8601-A2A69FE09E0E}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>CordovaDeploy</RootNamespace>
+ <AssemblyName>CordovaDeploy</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Smartdevice.Connectivity, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\..\..\..\Program Files (x86)\Common Files\microsoft shared\Phone Tools\CoreCon\10.0\Bin\Microsoft.Smartdevice.Connectivity.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/00955c48/tooling/CordovaDeploy/CordovaDeploy/Program.cs
----------------------------------------------------------------------
diff --git a/tooling/CordovaDeploy/CordovaDeploy/Program.cs b/tooling/CordovaDeploy/CordovaDeploy/Program.cs
new file mode 100644
index 0000000..003509d
--- /dev/null
+++ b/tooling/CordovaDeploy/CordovaDeploy/Program.cs
@@ -0,0 +1,188 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.SmartDevice.Connectivity;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Xml.XPath;
+using System.Xml;
+using System.Xml.Linq;
+
+namespace CordovaDeploy
+{
+ class Program
+ {
+
+ static void Log(string msg)
+ {
+ Debug.WriteLine(msg);
+ Console.Error.WriteLine(msg);
+ }
+
+ static void Usage()
+ {
+ Log("Usage:");
+ }
+
+
+
+ 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 Guid ReadAppId(string root)
+ {
+ Guid appID = Guid.Empty;
+ string manifestFilePath = root + @"\WMAppManifest.xml";
+
+ if (File.Exists(manifestFilePath))
+ {
+ XDocument xdoc = XDocument.Load(manifestFilePath);
+ var appNode = xdoc.Root.Descendants("App").FirstOrDefault();
+ if (appNode != null)
+ {
+ string guidStr = appNode.Attribute("ProductID").Value;
+ appID = new Guid(guidStr);
+ }
+ else
+ {
+ Log(string.Format("Unable to find appID, expected to find an App.ProductID property defined in the file {0}", manifestFilePath));
+ }
+ }
+ else
+ {
+ Log(string.Format("Error: the file {0} does not exist", manifestFilePath));
+ }
+
+
+ return appID;
+ }
+
+ static void Main(string[] args)
+ {
+ string iconFilePath = "";
+ string xapFilePath = "";
+ Guid appID = Guid.Empty;
+
+ string root = Directory.GetCurrentDirectory();
+
+ if (args.Length < 1)
+ {
+ Usage();
+ return;
+ }
+ else if (args[0] == "-devices")
+ {
+ ListDevices();
+ return;
+ }
+
+ 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)
+ {
+ return;
+ }
+
+ if (File.Exists(root + @"\ApplicationIcon.png"))
+ {
+ iconFilePath = root + @"\ApplicationIcon.png";
+ }
+ else
+ {
+ Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"));
+ return;
+ }
+
+
+ xapFilePath = Directory.GetFiles(root, "*.xap").FirstOrDefault();
+ if (string.IsNullOrEmpty(xapFilePath))
+ {
+ Log(string.Format("Error: could not find application .xap in folder {0}", root));
+ return;
+ }
+
+
+ // Get CoreCon WP7 SDK
+ DatastoreManager dsmgrObj = new DatastoreManager(1033);
+ Collection<Platform> WP7SDKs = dsmgrObj.GetPlatforms();//.Single(p => p.Name == "New Windows Mobile 7 SDK");
+
+ Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
+
+ Collection<Device> devices = null;
+
+ 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");
+
+ if (WP7Device != null)
+ {
+ RemoteApplication app;
+ bool isConnected = WP7Device.IsConnected();
+
+ Debug.WriteLine(WP7Device.ToString());
+
+ if (!isConnected)
+ {
+ try
+ {
+ WP7Device.Connect();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ return;
+ }
+ }
+
+ if (args.Contains("-r") && WP7Device.IsApplicationInstalled(appID))
+ {
+ Log("Uninstalling sample XAP to Windows Phone 7 Emulator/Device...");
+
+ app = WP7Device.GetApplication(appID);
+ app.Uninstall();
+
+ Log("Sample XAP Uninstalled from Windows Phone 7 Emulator/Device...");
+ }
+
+ 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...");
+ app.Launch();
+
+ Log("Launched app on Windows Phone 7 Emulator..." + app.InstanceID.ToString());
+
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/00955c48/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs b/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3c26c87
--- /dev/null
+++ b/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CordovaDeploy")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CordovaDeploy")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("256b11aa-d4bb-48cf-8024-7c040421fa8d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]