This is a hello world project demonstrating how to pack a CPP program to a windows MSIX package.
The project is highly inspired by offical document on creating package from source.
- build a small console program using CPP
- pack it to MSIX installer
- install it on the local machine
- distribute the app to Microsoft Store
- MSVC compiler and Windows SDK.
- CMake
- VScode
💡 no visual studio needed
Settings -> Update& security -> For developer
💡 you can check if you have enabled develop mode in PowerShell:
❯ Get-WindowsDeveloperLicense
ExpirationTime IsValid
-------------- -------
12/31/9999 8:00:00 AM True
- Build a CPP executable.
- Create an
appxmanifest.xml
file - Fill the required the information in
appxmanifest.xml
file follow the official document - Create and import a certificate
- Pack the runtime files with
makeappx.exe
from windows SDK - Sign the app with a certificate
create a certificate to sign an app
New-SelfSignedCertificate -Type Custom -Subject "CN=Tonghao, O=Tonghao, L=Shanghai, S=Shanghai, C=China" -KeyUsage DigitalSignature -FriendlyName "TonghaoCert" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
💡 make sure CN=Tonghao, O=Tonghao, L=Shanghai, S=Shanghai, C=China matches the one in appxmanifest
💡 replace TonghaoCert with what you like
💡 see the official document for details.
$password = ConvertTo-SecureString -String 123 -Force -AsPlainText
Export-PfxCertificate -cert "Cert:\CurrentUser\My\31FD5691A428FD73B26ECEB1E571929BCEF9FFD0" -FilePath d:\oss\hello_msix\tonghao.pfx -Password $password
💡 modify the 123 and d:\oss\hello_msix\tonghao.pfx if needed
SignTool sign /fd SHA256 hello.msix
💡 see the official document for details
-
build the executables with CMake
mkdir build && cd build && cmake ..
You should now see the installer hello.msix in the root directory and install the app by double click the hello.msxi
-
Install:
Add-AppxPackage -Register AppxManifest.xml
-
Get installed package:
❯ Get-AppxPackage -Name Tonghao.Yuan.hello Name : Tonghao.Yuan.hello Publisher : CN=Tonghao, O=Tonghao, L=Shanghai, S=Shanghai, C=China Architecture : X64 ResourceId : Version : 1.0.0.0 PackageFullName : Tonghao.Yuan.hello_1.0.0.0_x64__nqywa46cgs0va InstallLocation : C:\Program Files\WindowsApps\Tonghao.Yuan.hello_1.0.0.0_x64__nqywa46cgs0va IsFramework : False PackageFamilyName : Tonghao.Yuan.hello_nqywa46cgs0va PublisherId : nqywa46cgs0va IsResourcePackage : False IsBundle : False IsDevelopmentMode : False NonRemovable : False IsPartiallyStaged : False SignatureKind : Developer Status : Ok
-
Uninstall:
Remove-AppxPackage -Package "Tonghao.Yuan.hello_nqywa46cgs0va"
💡 You can also uninstall the app from the start menu