gpt4 book ai didi

windows-phone-8.1 - 如何将 .appx 部署到 Windows Phone 8.1

转载 作者:行者123 更新时间:2023-12-03 09:14:17 24 4
gpt4 key购买 nike

我按照此链接中的说明使用 Microsoft.SmartDevice.Connectivity 连接到 Windows Phone 8.1 操作系统:connect to windows phone 8 using console application
现在我可以连接到 Windows Phone 8.1 模拟器或 Windows Phone 8.1 设备,并且我可以使用它们的 ProductID 启动任何应用程序。
所以现在我想使用这个框架将我开发的应用程序安装到这些设备上。我知道 WP8.1 的 XAP 包是一个 .appx 文件。要在此框架中安装 1 个应用程序,我使用 InstallApplication() 方法,如下所示:

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

ProductID是哪个appID,我在Package.appxmanifest页面中得到的是:
556ee9d4-5640-4120-9916-44b1ca27352f
但我得到的异常(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."

当我使用Visual Studio提供的Application Deployment工具时,可以安装这个应用程序,但是当我使用connectivity framework时,我无法安装它。
那么如何使用 Connectivity Framework 安装此应用程序呢?
请帮我。感谢您的帮助。

最佳答案

是的,SmartDevice.Connectivity 的 AFAIK v11 将无法部署 APPX。您将需要 V12 来部署 APPX。 API 是如此不同,甚至部署 WP8.1 APPX 的工具与部署 WP7-WP8.0 XAP 的工具是不同的工具。

XAP deployment tool vs. 8.1 APPX deployment tool

无论如何,您可以使用此 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 已成功部署在我的机器上,一切正常,应用程序已按预期安装。

Foo Bar Baz Test app successfully installs

如果您想更喜欢 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,
}
}

Works on my machine

关于windows-phone-8.1 - 如何将 .appx 部署到 Windows Phone 8.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26303604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com