Learn how to develop Windows app with winappCLI and vibe coding!
-
Install Visual Studio 2022 Community Edition:
winget install Microsoft.VisualStudio.2022.Community -
Install WinApp CLI:
winget install Microsoft.winappcli --source winget
-
Initialize dependencies and generate development certificate:
winapp init . --no-prompt
Note: The
winapp initcommand is required to generate thedevcert.pfxfile, which is used for signing the package during development. This certificate contains a private key and should not be checked into version control (it is added to.gitignoreautomatically). -
Build with CMake:
cmake -S . -B build # This is the default settings with VS 2022, or... cmake -G "NMake Makefiles" -B build # Or, you can use nmake for building. cmake --build build --config Release
After building the project, the output directory (build/bin) contains the following structure, which adheres to the required package layout for Windows apps:
build/bin/
├── winapp-cpp-tutorial.exe # Main executable
├── Calculator.dll # WinRT Component
├── Calculator.winmd # Windows Metadata for the component
├── AppxManifest.xml # Package manifest (copied from appxmanifest.xml)
└── Assets/ # Image assets
To allow the executable to load the custom WinRT component (Calculator.dll) without installing it via MSIX (Side-loading), we use a Side-by-Side Manifest (app.manifest).
app.manifest: This file contains a<file>element with an<activatableClass>tag. It tells the OS thatWinAppTutorial.Calculatoris implemented inCalculator.dll.- Compilation: CMake is configured to embed
app.manifestintowinapp-cpp-tutorial.exeas a resource (RT_MANIFEST). This means you do not need to distributeapp.manifestseparately; it is part of the binary.
The appxmanifest.xml file is used when packaging the app as an MSIX bundle.
- In-Process Server Limitation: Standard
appxmanifest.xmlvalidation for Packaged Classic Apps (runFullTrust) often rejectswindows.activatableClass.inProcessServerextensions. - Solution: By using the embedded
app.manifest(Reg-Free WinRT), the application handles component activation internally, bypassing the need to declare the ActivatableClass inappxmanifest.xmlfor the desktop bridge scenario.