如何将APPX部署到运行Windows Phone模拟器?

时间:2015-04-20 19:45:17

标签: c# windows-phone-8 deployment windows-phone windows-8.1

我正在尝试将C#中的 appx 软件包部署到Windows Phone模拟器,如下所示:

How to deploy an .appx into Windows Phone 8.1

问题是方法GetDevices()返回这样的设备列表:

  • {设备}
  • {Emulator 8.1 WVGA 4英寸512MB(ES)}
  • {Emulator 8.1 WVGA 4 inch(ES)}
  • {Emulator 8.1 720P 4.7英寸(ES)}

我不知道为什么它会在最后添加(ES)。 执行代码后,模拟器启动但卡住了。它不起作用。

我可以改为使用已经运行的模拟器并选择那个吗?

2 个答案:

答案 0 :(得分:2)

试试吧。 但首先......

PRE REQUIREMENTS

  • Windows 8.1+作为操作系统
  • 已安装Windows Phone SDK 8.1

我确实创建了一个批处理脚本文件(.bat)来执行所需的所有步骤。 现在我有一些部署应用程序的麻烦。但它可以作为一个起点。

脚本如下:

@echo off
REM SOURCES
REM ------------------------------------------------------------------------------
REM Create a Windows Store AppX package and sign it
REM http://blogs.msdn.com/b/wsdevsol/archive/2014/02/12/create-a-windows-store-appx-package-and-sign-it.aspx
REM How to create an app package signing certificate
REM https://msdn.microsoft.com/pt-br/library/windows/desktop/jj835832(v=vs.85).aspx
REM How to sign an app package using SignTool
REM https://msdn.microsoft.com/pt-br/library/windows/desktop/jj835835(v=vs.85).aspx
REM ------------------------------------------------------------------------------
SET "WINDOWS_KIT_8_1_86X=%PROGRAMFILES(x86)%\Windows Kits\8.1\bin\x86\"
SET makeappxexe = "%PROGRAMFILES(x86)%\Windows Kits\8.1\bin\x86\makeappx.exe"
SET msbuildexe = "%PROGRAMFILES(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
SET "APP_DIRECTORY=%userprofile%\source\repos\MyAwesomeApp\App1"
SET "APP_PACKAGE_DIRECTORY=%userprofile%\source\repos\MyAwesomeApp\App1\AppPackages\"

@echo "building App1 project..."
%msbuildexe% "%APP_DIRECTORY%App1.csproj" /verbosity:quiet

REM App packager(MakeAppx.exe)
REM https://msdn.microsoft.com/en-us/library/windows/desktop/hh446767(v=vs.85).aspx
@echo "Creating APPX from App1 project..."
%makeappxexe% pack /o /v /l /d "%APP_DIRECTORY%" /p "%APP_PACKAGE_DIRECTORY%App1.appx"

REM MakeCert
REM https://msdn.microsoft.com/pt-br/library/windows/desktop/ff548309(v=vs.85).aspx
@echo "Making certificate..."
"%WINDOWS_KIT_8_1_86X%makecert.exe" /n "[PACKAGE.IDENTITY.PUBLISHER] LOCATED AT APPXMANIFEX.XML OR PACKAGE.APPXMANIFEST" /r /h 0 /eku "1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13" /e "12/30/2016" /sv "%APP_PACKAGE_DIRECTORY%Appp1Key.pvk" "%APP_PACKAGE_DIRECTORY%Appp1Key.cer"

REM Pvk2Pfx
REM https://msdn.microsoft.com/pt-br/library/windows/desktop/ff550672(v=vs.85).aspx
@echo "Making PFX file..."
"%WINDOWS_KIT_8_1_86X%Pvk2Pfx.exe" /f /pvk "%APP_PACKAGE_DIRECTORY%Appp1Key.pvk" /spc "%APP_PACKAGE_DIRECTORY%Appp1Key.cer" /pfx "%APP_PACKAGE_DIRECTORY%Appp1Key.pfx"

REM SignTool
REM https://msdn.microsoft.com/pt-br/library/windows/desktop/ff551778(v=vs.85).aspx
@echo "Signing APPX..."
"%WINDOWS_KIT_8_1_86X%SignTool.exe" sign /fd SHA256 /a /f "%APP_PACKAGE_DIRECTORY%Appp1Key.pfx" "%APP_PACKAGE_DIRECTORY%App1.appx"

REM Deploy Windows Phone 8.1 apps with the Application Deployment tool
REM https://msdn.microsoft.com/en-us/library/dn632395.aspx
@echo "Deploying App1 to emulator..."
"C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\AppDeployCmd.exe" /installlaunch "%APP_PACKAGE_DIRECTORY%App1.appx" /targetdevice:6
@echo "Deploying App1 to device..."
"C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\AppDeployCmd.exe" /installlaunch "%APP_PACKAGE_DIRECTORY%App1.appx" /targetdevice:de

您还可以构建您的项目(它将自动生成Appx)并使用自动生成的Appx按如下方式部署到模拟器或设备:

SET "APP_DIRECTORY=%userprofile%\source\repos\MyAwesomeApp\App1"
SET "APPX_PATH=%userprofile%\source\repos\MyAwesomeApp\App1\AppPackages\App1_1.0.0.0_x86_Test\App1_1.0.0.0_x86.appx"

@echo "building App1 project..."
"%PROGRAMFILES(x86)%\MSBuild\14.0\Bin\MSBuild.exe" "%APP_DIRECTORY%\App1.csproj" -t:Rebuild -p:Configuration=Release;BuildPlatform=x86 /verbosity:minimal /nologo

REM Deploy Windows Phone 8.1 apps with the Application Deployment tool
REM https://msdn.microsoft.com/en-us/library/dn632395.aspx
@echo "Deploying App1 to emulator..."
"C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\AppDeployCmd.exe" /installlaunch "%APPX_PATH%" /targetdevice:6
@echo "Deploying App1 to device..."
"C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\AppDeployCmd.exe" /installlaunch "%APPX_PATH%" /targetdevice:de

我希望它对您有所帮助,但如果您已找到解决方案,请告诉我。

答案 1 :(得分:1)

您可以尝试使用应用程序部署工具(XapDeploy.exe),有关详细信息,请访问以下链接:https://msdn.microsoft.com/en-us/library/windows/apps/ff402565(v=vs.105).aspx

一步一步:

  1. 您还可以使用Windows Phone应用程序部署工具(XapDeploy.exe)来部署您的应用程序。此工具是安装Windows Phone SDK时安装的独立应用程序。
  2. 您可以使用文件夹C:\ Program Files(x86)\ Microsoft SDKs \ Windows Phone \ v8.0 \ Tools \ XAP Deployment中安装的应用程序部署工具的版本来部署面向Windows Phone OS 8.0或Windows Phone OS 7.1。 您只能使用文件夹C:\ Program Files(x86)\ Microsoft SDKs \ Windows Phone \ v7.1 \ Tools \ XAP Deployment中安装的应用程序部署工具的版本来部署面向Windows Phone OS 7.1的应用程序。
  3. 使用“应用程序部署”工具部署应用程序
  4. 构建您的应用。
  5. 如果您要将应用程序部署到已连接的设备,请确保已完成本主题前面列出的先决条件。 从Windows“开始”屏幕,启动“应用程序部署”工具。您可以通过打开所有应用程序视图并在Windows Phone SDK 8.0组中找到它来查找应用程序部署工具,或者从“开始”屏幕键入“应用程序部署”以搜索它。
  6. 您还可以从以下位置运行该工具: C:\ Program Files(x86)\ Microsoft SDKs \ Windows Phone \ v8.0 \ Tools \ XAP Deployment \ XapDeploy.exe
  7. 在“目标”下拉框中,选择一个模拟器选项。
  8. 单击“浏览”并找到要部署的XAP文件。
  9. 单击“部署”。
  10. 如果部署成功,“状态”字段将显示“XAP部署完成”。