Compartir a través de


Preparing company apps for distribution for Windows Phone

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Before distributing a company app or a Company Hub app to employees or other users, you must prepare the app for distribution by performing the following tasks:

  • Precompile any managed assemblies that are included in the package into native code.

  • Sign the package with the enterprise certificate that you obtained from Symantec. For more info about obtaining the certificate, see Company app distribution for Windows Phone.

You can complete both tasks by running one of the PowerShell scripts that are included with the Windows Phone development tools. For more info, see Precompiling managed assemblies and signing apps by using the Windows PowerShell script in this topic.

For Windows Phone 8 apps, you also have the following options:

Precompiling managed assemblies and signing apps by using the PowerShell scripts

The Windows Phone development tools provide PowerShell scripts that call command-line tools to precompile and sign your app. These PowerShell scripts have the advantage of automating some tasks that you have to do manually when you call the individual tools directly. In most scenarios, consider using the PowerShell scripts unless you need other options provided by the individual tools.

For more info about Windows PowerShell, see Windows PowerShell.

Windows Phone 8 apps

Run the BuildMDILXap.ps1 script, which is in the %ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\MDILXAPCompile folder.

The following table describes the arguments for the BuildMDILXap.ps1 script.

Argument

Description

-xapfilename XAP

(required)

The full path of the XAP file to precompile (and to sign, if the -pfxfilename option is specified).

-pfxfilename PFXFile

(optional)

Signs the XAP with the PFX file generated from the enterprise mobile code-signing certificate provided by Symantec. If the PFX file is not in the current path, specify the full path to the file.

-password Password

(optional)

The password to use to read the PFX file.

The following example demonstrates how to launch PowerShell and run the BuildMDILXap.ps1 script at the command prompt. Be sure to replace the file paths and password in this example with the relevant values.

powershell.exe -File "%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\MDILXAPCompile\BuildMDILXap.ps1" -xapfilename "%UserProfile%\Documents\CompanyApps\Contoso.xap" –pfxfilename "%UserProfile%\Documents\Certificates\ContosoCert.pfx" -password mystrongpassword

Windows Phone 8.1 Silverlight apps

Run the BuildMDILSL81XAP.ps1 script, which is in the C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\MDILXAPCompile folder.

All parameters for BuildMDILSL81XAP.ps1 are optional. To learn more about the parameters and to see sample scripts, open the BuildMDILSL81XAP.ps1 file in the editor.

  • If you simply run BuildMDILSL81XAP.ps1 without any arguments, the script prompts you to select a XAP package to optimize. The package is not signed.

  • If you typically use the script to sign packages with the same certificate path and the same password, modify the script to make those values the default values of the $pfxfilename and $password variables.

  • If you sign the package and provide a value for the optional –mailkeypath parameter, the script creates a draft Outlook email message that contains the optimized XAP package along with the associated .AETX file for distribution through email. The new mail message may open behind the active window.

The following example demonstrates how to launch PowerShell and run the BuildMDILSL81XAP.ps1 script at the command prompt. Be sure to replace the file paths and password in this example with the relevant values.

powershell.exe -File "%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.1\Tools\MDILXAPCompile\BuildMDILSL81XAP.ps1" -xapfilename "%UserProfile%\Documents\CompanyApps\Contoso.xap" –pfxfilename "%UserProfile%\Documents\Certificates\ContosoCert.pfx" -password mystrongpassword

Windows Phone 8.1 Windows Runtime apps

Run the BuildMDILAPPX.ps1 script, which is in the C:\Program Files (x86)\Microsoft SDKs\WindowsPhoneApp\v8.1\Tools\MDILXAPCompile folder.

All parameters for BuildMDILAPPX.ps1 are optional. To learn more about the parameters and to see sample scripts, open the BuildMDILAPPX.ps1 file in the editor.

  • If you simply run BuildMDILAPPX.ps1 without any arguments, the script prompts you to select an APPX package to optimize. The package is not signed.

  • If you typically use the script to sign packages with the same certificate path and the same password, modify the script to make those values the default values of the $pfxfilename and $password variables.

  • If you sign the package and provide a value for the optional –mailkeypath parameter, the script creates a draft Outlook email message that contains the optimized APPX package along with the associated .AETX file for distribution through email. The new mail message may open behind the active window.

The following example demonstrates how to launch PowerShell and run the BuildMDILAPPX.ps1 script at the command prompt. Be sure to replace the file paths and password in this example with the relevant values.

powershell.exe –File "%ProgramFiles(x86)%\Microsoft SDKs\WindowsPhoneApp\v8.1\Tools\MDILXAPCompile\BuildMDILAPPX.ps1" -appxfilename C:\temp\fabk.appx -pfxfilename C:\temp\cert01.pfx -password mypassword

Precompiling managed assemblies and signing apps at the command prompt by using MSBuild (Windows Phone 8 apps only)

You can also build Windows Phone 8 your app, precompile its assemblies, and sign it at the command prompt by using the MSBuild tool. You can build an app from a script or from a custom app by calling this tool.

Important Note:

If you’re building apps with Visual Studio 2012, command-line precompilation and signing for Windows Phone 8 projects require Visual Studio 2012 Update 2 or later. The command-line properties described in this section are not included in the download of the Windows Phone SDK 8.0.

To precompile managed assemblies at the command prompt by using MSBuild

  • To precompile managed assemblies, use the MDILCompile command-line property with MSBuild.

    For example:

    msbuild /p:MDILCompile=true …
    

To sign the XAP at the command prompt by using MSBuild

  • To sign the XAP, use the SignXap command-line property with MSBuild.

    The SignXap property also requires values for the following two properties:

    • SignKeyFile: The fully qualified file name of the signing key.

    • SignKeyPassword: The password for the signing key file.

    For example:

    msbuild /p:SignXap=true /p:SignKeyFile=C:\MyFile\MyPvt.pfx /p:SignKeyPassword=abc%$^abc …
    

For more info about MSBuild, see MSBuild and MSBuild Reference.

See Also

Other Resources

How to precompile a company app using MDILXAPCompile for Windows Phone

How to sign a company app using XapSignTool for Windows Phone