是的,SmartDevice.Connectivity 的 AFAIK v11 将无法部署 APPX。您需要 V12 来部署 APPX。API 是如此不同,即使部署 WP8.1 APPX 的工具与部署 WP7-WP8.0 XAP 的工具不同。
无论如何,您可以使用以下 C# 代码部署 Windows Phone 8.1 APPX:
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();
}
当我尝试运行它时,APPX 已成功部署在我的机器上,一切正常,并且应用程序按预期安装。
如果您想更好地使用 Windows Phone 8.1 模拟器/设备自动化(在 SD 卡上安装、删除、企业安装等),您可以尝试不同的 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,
}
}