This is a library of utilities for dealing programmatically with Windows Phone applications, used namely for tools like Titanium.
JavaScript C# C++ PowerShell C
Latest commit 5ea4f99 Dec 20, 2016 @infosia infosia committed on GitHub Update uuid to version 3.0.0 (#63)
Permalink
Failed to load latest commit information.
bin
lib
test
wptool
wstool
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
index.js
package.json

README.md

Windows Phone Utility Library Build Status

This is a library of utilities for dealing programmatically with Windows Phone applications, used namely for tools like Titanium.

windowslib supports Visual Studio 2012, 2013, and 2015.

NPM

Installation

From NPM:

npm install windowslib

From GitHub:

npm install git://github.com/appcelerator/windowslib.git

Caveats

  • Some of the emulator detection functionality requires the use of PowerShell scripts. For the library to be able to execute these scripts, the user must change their ExecutionPolicy by running the following in a PowerShell terminal as the Administrator:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • If attempting to connect to a device, you need to ensure the connected device is not asleep/locked or connecting will fail. There's no way to programmatically unlock the device.

Examples

Detect all the connected Windows Phone devices:

Note: Microsoft's tooling always reports a single device present regardless if there are no devices connected or several. The device will have an ID of 0 (zero).

In the event Microsoft's next mobile platform has improved tooling that supports multiple devices, this detection code should be good to go.

var windowslib = require('windowslib');

windowslib.device.detect(function (err, devices) {
    if (err) {
        console.error(err);
    } else {
        console.log(devices);
    }
});

Install an Application on Device

var deviceUDID = null; // string or null to pick first device

windowslib.device.install(deviceUDID, 'C:\\path\\to\\appfile.appx')
    .on('installed', function () {
        console.log('App successfully installed on device');
    })
    .on('error', function (err) {
        console.error(err);
    });

Launch the Windows Phone Emulator

Passing in null for the udid will auto-select a emulator and launch it.

windowslib.emulator.launch(null, function (err, handle) {
    console.log('Emulator launched');
    windowslib.emulator.stop(handle, function () {
        console.log('Emulator stopped');
    });
});

Launch, install, and Run an Application on the Emulator

var udid = null; // string or null to pick an emulator

windowslib.emulator.install(udid, 'C:\\path\\to\\appfile.appx')
    .on('launched', function (msg) {
        console.log('Emulator has launched');
    })
    .on('appStarted', function (msg) {
        console.log('App has started');
    })
    .on('log', function (msg) {
        console.log('[LOG] ' + msg);
    })
    .on('error', function (err) {
        console.error(err);
    });

Force Stop an Application Running on the Emulator

windowslib.emulator.launch(udid)
    .on('launched', function (handle) {
        console.log('Emulator launched');
        windowslib.emulator.stop(handle).on('stopped', function () {
            console.log('Emulator stopped');
        });
    });

Detect Everything

windowslib.detect(function (err, info) {
    if (err) {
        console.error(err);
    } else {
        console.log(info);
    }
});

Running Tests

For best results, connect a Windows phone device.

To run all tests:

npm test

To run a specific test suite:

npm run-script test-assemblies

npm run-script test-device

npm run-script test-emulator

npm run-script test-env

npm run-script test-logrelay

npm run-script test-process

npm run-script test-visualstudio

npm run-script test-windowsphone

npm run-script test-wptool

Reporting Bugs or Submitting Fixes

If you run into problems, and trust us, there are likely plenty of them at this point -- please create an Issue or, even better, send us a pull request.

Contributing

windowslib is an open source project. windowslib wouldn't be where it is now without contributions by the community. Please consider forking windowslib to improve, enhance or fix issues. If you feel like the community will benefit from your fork, please open a pull request.

To protect the interests of the windowslib contributors, Appcelerator, customers and end users we require contributors to sign a Contributors License Agreement (CLA) before we pull the changes into the main repository. Our CLA is simple and straightforward - it requires that the contributions you make to any Appcelerator open source project are properly licensed and that you have the legal authority to make those changes. This helps us significantly reduce future legal risk for everyone involved. It is easy, helps everyone, takes only a few minutes, and only needs to be completed once.

You can digitally sign the CLA online. Please indicate your email address in your first pull request so that we can make sure that will locate your CLA. Once you've submitted it, you no longer need to send one for subsequent submissions.

Legal

Copyright (c) 2014-2015 by Appcelerator, Inc. All Rights Reserved. This project is licensed under the Apache Public License, version 2. Please see details in the LICENSE file.