Packaging Universal Windows Platform (UWP) Apps
This guide covers the essential aspects of packaging your Universal Windows Platform (UWP) applications, ensuring they are ready for distribution and installation on Windows devices.
On This Page
Understanding Package Formats
UWP apps are distributed using the App Package (APPX) format. This format is a container for all the files required to run your application, including executables, assets, and the application manifest. For specific deployment scenarios, such as enterprise or sideloading, you might also encounter the MSIX format, which is an evolution of APPX.
APPX vs. MSIX
- APPX: The original package format for UWP apps.
- MSIX: A modern packaging format that improves upon APPX, offering features like cleaner installations, better updates, and support for non-UWP Win32 applications. While UWP apps can be packaged as MSIX, the core concepts remain similar.
Creating a Package
The primary tool for creating UWP app packages is Visual Studio. Follow these steps to generate your package:
- Open your UWP project in Visual Studio.
- In Solution Explorer, right-click on your project and select Publish > Create App Packages....
- Choose whether to package for the Microsoft Store or for sideloading/enterprise distribution.
- Select the target architectures (x86, x64, ARM, ARM64) and the build configuration (Debug or Release).
- Visual Studio will guide you through the process of generating the package files, including signing options.
The Package Manifest (appxmanifest.xml)
The appxmanifest.xml file is the heart of your application's package. It contains crucial metadata about your app, including:
- Identity: Package name, publisher, version.
- Resources: Visual assets (icons, splash screens), languages, scale, DirectX support.
- Capabilities: Permissions your app requires (e.g., Internet (Client), Location, Microphone).
- Application: Entry point, display name, background tasks, visual elements.
- Prerequisites: Minimum OS version required.
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10/1"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10/1"
xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10/1"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10/1"
IgnorableNamespaces="uap mp desktop build">
<Identity Name="YourApp.YourPackageName" Publisher="CN=YourPublisherID" Version="1.0.0.0" ProcessorArchitecture="neutral" />
<mp:PhoneIdentity PhoneProductId="{your-guid}" />
<Properties>
<DisplayName>My Awesome UWP App</DisplayName>
<PublisherDisplayName>Your Company Name</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10240.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-default" />
</Resources>
<Applications>
<Application Id="App" Executable="YourApp.exe" EntryPoint="YourApp.App">
<uap:VisualAssets
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="My Awesome UWP App">
<uap:SplashScreen Image="Assets\SplashScreen.png" />
<uap:TileVisual Size="2x2" VisualAssets="Assets\Square150x150Logo.png"/>
</uap:VisualAssets>
<uap:ApplicationModel>
<uap:ActivatableClass ActivatableClassId="YourApp.BackgroundTasks.MyBackgroundTask" ThreadGroupName="MainThread" />
</uap:ApplicationModel>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="location" />
</Capabilities>
</Package>
Signing Your Package
All app packages must be signed with a digital certificate. This signature verifies the authenticity of the publisher and ensures the package has not been tampered with since it was signed.
- Microsoft Store: Packages submitted to the Microsoft Store are signed by Microsoft.
- Sideloading/Enterprise: For sideloading, you will typically use a developer certificate generated by Visual Studio or a trusted certificate from a certificate authority. For enterprise distribution, you might use an enterprise certificate.
Visual Studio handles certificate management during the package creation process. You can choose to use an existing certificate or create a new one.
Testing and Deployment
Before widespread distribution, it's crucial to test your packaged application.
- Sideloading: You can install your generated APPX or MSIX package on a test machine by double-clicking the file or using PowerShell cmdlets like
Add-AppxPackage. - Testing on Devices: Deploy your app to various Windows devices (desktops, tablets, Xbox, HoloLens) to ensure compatibility and performance.
- Deployment Methods:
- Microsoft Store
- Enterprise distribution (Intune, SCCM)
- Sideloading
Thorough testing helps identify any packaging-related issues before releasing your app to users.