How to deploy .appx on Windows Phone 8.1

I am using Microsoft.SmartDevice.Connectivity to connect to Windows Phone 8.1 OS with the instruction at this link: connect to phone 8 window using console app
Now I can connect to both Windows Phone 8.1 emulator and Windows Phone 8.1 device and I can run any application using their ProductID.
So now I would like to install my applications that I have developed for this device using this framework. I know the WP8.1 XAP package is an .appx file. To install 1 application in this framework, I use the InstallApplication () method like this:

 IRemoteApplication remoteApplication = iDevice.InstallApplication(appID, appID, applicationGenre, iconPath, xapPackage);

      

What appID is the ProductID, I got it on the Package.appxmanifest page:
556ee9d4-5640-4120-9916-44b1ca27352f


But I got an exception:

"An unhandled exception of type 'Microsoft.SmartDevice.Connectivity.SmartDeviceException' occurred in Microsoft.Smartdevice.Connectivity.dll

Additional information: An attempt was made to move the file pointer before the beginning of the file."

      

When I use the Application Deployment Tool provided by Visual Studio, this application can be installed, but when I use the Connectivity Framework, I cannot install it.
So how can I install this app using the Connectivity Framework?
 Please help me. Thank you for your help.

+2


source to share


1 answer


Yes, AFAIK v11 SmartDevice.Connectivity won't be able to deploy APPX. You will need V12 to deploy APPX. The APIs are so different that even the WP8.1 APPX deployment tool is a different tool and the other is WP7-WP8.0 XAP application deployment.

XAP deployment tool vs.  8.1 APPX deployment tool

Anyway, you can deploy your Windows Phone 8.1 APPX application using this C # code:

static void Main(string[] args)
{
    // step #1: Add refrences. 
    // - Add DLL reference to: C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\Microsoft.Phone.Tools.Deploy.dll
    // GAC references are implicit on computers with VS2013/VS2014 installed alongside WP8.1 dev tools. 
    // - GAC reference to: Microsoft.Phone.Tools.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    // - GAC reference to: Microsoft.SmartDevice.Connectivity.Interface, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    // - GAC reference to: Microsoft.SmartDevice.MultiTargeting.Connectivity, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    try
    {
        // Step #2: Get devices
        var devices = Utils.GetDevices();

        Console.WriteLine("Possible Devices for deployment: ");
        foreach (var deviceInfo in devices)
        {
            Console.WriteLine("\t" + deviceInfo.ToString());
        }

        // Step #3: choose a device
        var device = devices.FirstOrDefault(d => d.ToString() == "Emulator 8.1 1080P 6 inch");

        if (device == null)
            return;
        Console.WriteLine("Using device: " + device.ToString());


        // step #4: Select XAP, DeploymentOptions and Manifest
        string appxFileUri = @"D:\Users\Justin Angel\Documents\Visual Studio 2013\Projects\App15\App15\AppPackages\App15_1.1.0.0_AnyCPU_Test\App15_1.1.0.0_AnyCPU.appx";
        IAppManifestInfo manifestInfo = Utils.ReadAppManifestInfoFromPackage(appxFileUri); ;
        DeploymentOptions deploymentOptions = DeploymentOptions.None;

        // Step #5: deploy
        Console.WriteLine("Attempting to deploy: " + manifestInfo.Name + " from " + appxFileUri);
        Utils.InstallApplication(device, manifestInfo, deploymentOptions, appxFileUri);
        Console.WriteLine("deployed successfully");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Failed to deploy");
    }

    Console.ReadKey();
}

      

When I try to run this, APPX is successfully deployed to my machine, everything works fine and the application is installed as expected.



Foo Bar Baz Test app successfully installs

If you want to fall in love with Windows Phone 8.1 Emulator / Device automation (install to SD card, uninstall, install in enterprise, etc.), you can play with various DeploymentOptions:

namespace Microsoft.Phone.Tools.Deploy
{
  [Flags]
  public enum DeploymentOptions
  {
    None = 0,
    PA = 1,
    Debug = 2,
    Infused = 4,
    Lightup = 8,
    Enterprise = 16,
    Sideload = 32,
    TypeMask = 255,
    UninstallDisabled = 256,
    SkipUpdateAppInForeground = 512,
    DeleteXap = 1024,
    InstallOnSD = 65536,
    OptOutSD = 131072,
  }
}

      

Works on my machine

+6


source







All Articles