Windows 10 – Unpacking and Packing AppX

email me

These are some of my notes for working with AppX files.

You will need to install the SDK to use MakeAppx.exe, and make sure Developer Mode is enabled.

 

Developer Mode

reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock” /v “AllowDevelopmentWithoutDevLicense” /t REG_DWORD /d “1” /f /reg:64

reg.exe add “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock” /v AllowAllTrustedApps /t REG_DWORD /d 1 /f /reg:64

reg.exe add “HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Appx” /v AllowDevelopmentWithoutDevLicense /t REG_DWORD /d 1 /f /reg:64

reg.exe add “HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Appx” /v AllowAllTrustedApps /t REG_DWORD /d 1 /f /reg:64

 


Example SDK folder (location of tools)

C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64

 

Unbundle

MakeAppx.exe unbundle /p C:\example\AppleInc.iTunes_12090.167.37085.0_neutral_~_nzyj5cx40ttqa.AppxBundle /d C:\example\unbundle

 

Unpack

MakeAppx.exe unpack /p C:\example\unbundle\AppleInc.iTunes_12090.167.37085.0_x64.appx /d C:\example\unpack

 

Pack

MakeAppx pack /d C:\example\pack /p C:\example\sample1.appx

 


If you receive errors

Get-Appxlog | Out-GridView

 

Notes

Examples

MakeAppx pack /v /h SHA256 /d “C:\My Files” /p MyPackage.appx
MakeAppx pack /v /o /f MyMapping.txt /p MyPackage.appx
MakeAppx pack /m “MyApp\AppxManifest.xml” /f MyMapping.txt /p AppPackage.appx
MakeAppx pack /r /m “MyApp\AppxManifest.xml” /f MyMapping.txt /p ResourcePackage.appx
MakeAppx pack /v /h SHA256 /d “C:\My Files” /ep MyPackage.eappx /kf MyKeyFile.txt
MakeAppx pack /v /h SHA256 /d “C:\My Files” /ep MyPackage.eappx /kt
MakeAppx pack /v /h SHA256 /d “C:\My Files” /ep MyPackage.eappx /kt /np
MakeAppx pack /v /h SHA256 /d “C:\My Files” /p MyPackage.appx /ml 1073741824

 

Manually install unpacked AppX file

Add-AppxPackage -Path C:\example\AppxManifest.xml -Register


Signing your packages

makecert.exe -r -h 0 -n “CN=Publisher” -eku 1.3.6.1.5.5.7.3.3 -pe -sv C:\example\PackageCert.pvk C:\example\PackageCert.cer

pvk2pfx.exe -pvk C:\example\PackageCert.pvk -spc C:\example\PackageCert.cer -pfx C:\example\PackageCert.pfx

SignTool.exe sign /a /v /fd SHA256 /f C:\example\PackageCert.pfx C:\example\MyApp.appx

 

Manually add AppX file

Add-AppxPackage C:\Path\to\application.appx

 

All About AppX

What is an AppX?

The AppX is the file format used to distribute and install apps on the Universal Windows Platform. The AppX is an .ZIP-based container file.

What does an AppX package contain?

Each Windows Runtime app package contains the app’s payload files plus info needed to validate, deploy, manage, and update the app.

In an AppX package you will find:

  • App payload which is the Application files
  • XML configuration files which are:
    • App manifest which is the app manifest file (AppxManifest.xml)
    • App block map which is the app package’s block map file (AppxBlockMap.xml)
  • App signature

What is the installation type of a UWP app?

The UWP app is installed per-user. Users don’t have any knowledge of what was installed for any other user.

Where the UWP apps get installed?

In UWP apps we have app isolation mechanism, which means they only impact the account of the user who installed them. The app binaries are stored on the drive (%ProgramFiles%\WindowsApps). Only the Operating System can write in that location. The application cannot write in that location; the application is running in a sandbox.

What is a UWP package?

The UWP packages are Win32 apps converted to AppX. Are also called full trusted apps.

How to install an AppX package from other sources that you trust, outside of the Windows Store?

A requirement is to have “Sideload apps” option enabled on your target machine from “Settings” -> “Update and security” -> “For developers”.

There are two ways to sideload apps after Windows 10 Anniversary Update:

  • Full trust apps: double-click the AppX file from Windows Explorer and follow the graphical installer
  • Untrusted apps:
    • import the security certificate used to sign the AppX into the system store
    • run PowerShell cmdlet as admin
    • run following command pointing to the AppX file on the target system:
Add-AppxPackage -Path "C:\Path\Your.AppX"

Why do I receive the “External tool not found: MakePri.exe” error during the UwpAppX build?

For creating UwpAppX packages with Advanced Installer, the build machine must have the latest Windows SDK installed.

Why do I receive the “Error: SignerSign() failed. (-2147024885/0x8007000b)” error during the UwpAppX build?

This error may occur if the ID field from the Package Information view does not match with the publisher subject information of the certificate used to sign the package.

I have just converted a classic desktop application to an AppX package, why do I receive the “Failed due to unknown reasons” when I try to install it?

This error may occur if you have not included in your Advanced Installer Project all the images in Visual Assets and Package Information for all the required resolutions and tile sizes.

Matteo Pagani’s blog post offers a solution for the same issue if you used Microsoft’s Desktop App Converter for the conversion.

Can I configure the default app launched at the end of the deployment of an AppX bundle?

When you install a multi-app package from the Windows Store, there is no [ Launch ] button. Instead, you are directed to the app list to choose what app you want to start, meaning you cannot have a default app for an AppX bundle.

How do I access the AppX installation log?

First, you have to launch the Event Viewer by going to Start > Event Viewer (Local).

Once in the Event Viewer go to Applications and Services Logs > Microsoft > Windows > AppxPackagingOM > Microsoft-Windows-AppxPackaging/Operational.

Why do I get the “Invalid package identity name” error?

The package identity name must be composed of the publisher/company name and the app name (i.e., YourCompanyName.YourAppName).

Microsoft automatically detects your company name from your Windows Developer account.

Why do I get the “Invalid package family name” error?

The package family name is generated by the OS (not Advanced Installer) starting from the package identity name. The OS appends a hash at the end of the name, which is generated from the package and publisher identify information.

You cannot directly set this name. As long as you set the package identity name (as Microsoft requires) and the CN, the package family name will be set correctly.

Why do I get the “Invalid package publisher name” error?

When you publish an app in the store you no longer need to sign it with your certificate; the Microsoft Store will do it instead. Digital signing is only required when you test the app on your local machine or if you plan to distribute it outside the Microsoft Store.

When you publish the app in the store, you need to disable digital signing in Advanced Installer and set the publisher ID in the project to the value from your Microsoft Developer account, i.e., CN=82A13EFD-FE37-4EFC-8BA4-1C3E9EFE5F23

Why do I get the “This package’s manifest uses a display name that you have not reserved” error?

You must log in to your Windows Developer account (sign up if you don’t have one) and reserve your application name. For more details about registering a Windows Developer account see Microsoft’s documentation.

 

Notes

reg Query “HKLM\Hardware\Description\System\CentralProcessor\0” | find /i “x86” > NUL && set OS=32BIT || set OS=64BIT

if %OS%==32BIT goto 32Bit
if %OS%==64BIT goto 64Bit