Restore WindowsAI CMake sample to support WinAppSDK 1.8 Experimental 2 - #474
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR restores the Windows AI CMake sample to support the WinAppSDK 1.8 Experimental 2 release by updating packaging, CMake configuration, and main application code. Key changes include:
- Adding and updating vcpkg port files for WindowsAppSDK support.
- Modifying main.cpp to accommodate Windows AI breaking API changes.
- Adjusting project configuration files (CMakeLists.txt, AppxManifest.xml, etc.) to align with experimental package requirements.
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Samples/WindowsAIFoundry/cpp-console-sparse/vcpkg_ports/windowsappsdk/windowsappsdk-config.cmake | Added imported target configurations for WindowsAppSdk libraries. |
| Samples/WindowsAIFoundry/cpp-console-sparse/vcpkg_ports/windowsappsdk/vcpkg.json | Introduced a new package configuration for WindowsAppSDK experimental version. |
| Samples/WindowsAIFoundry/cpp-console-sparse/vcpkg_ports/windowsappsdk/portfile.cmake | Updated portfile to acquire and install WindowsAppSDK and generate C++/WinRT headers. |
| Samples/WindowsAIFoundry/cpp-console-sparse/main.cpp | Updated sample code to handle Windows AI API changes and process command-line arguments. |
| Other project files (vcpkg.json, vcpkg-configuration.json, AppxManifest.xml, etc.) | Modified to support the new package identity and experimental package deployment. |
Comments suppressed due to low confidence (2)
Samples/WindowsAIFoundry/cpp-console-sparse/main.cpp:27
- [nitpick] The variable name 'instructions' could be more descriptive; consider renaming it to 'systemPrompt' to clearly indicate its purpose as the static system prompt.
std::wstring instructions = L"You are a clever storyteller. You write engaging one-paragraph stories that grab the imagination of an 8th grader. Tell a story about a dragon who says: ";
Samples/WindowsAIFoundry/cpp-console-sparse/CMakeLists.txt:43
- [nitpick] The variable 'ONEFILE' is ambiguous; renaming it to 'dllFile' or a similar descriptive name would improve code clarity.
foreach(ONEFILE ${TARGET_RUNTIME_DLLS})
| "generator": "Ninja", | ||
| "binaryDir": "${sourceDir}/out/build/${presetName}", | ||
| "architecture": { | ||
| "value": "x64", |
There was a problem hiding this comment.
Turns out that Ninja does not support setting the architecture, so all these are effectively the same (Ninja uses the values that vcvarsall.bat set from the "x64 native tools prompt" you're running in.)
Don't change anything now, but you can't actually use Ninja to "cross compile" target architectures. Cc Duncan Horn (@dunhor)
There was a problem hiding this comment.
In theory you can get it to work with a properly crafted toolchain file. That said, using the proper vcvars initialization script is significantly easier.
There was a problem hiding this comment.
It looks like maybe https://github.com/search?q=CMAKE_SYSTEM_PROCESSOR+Ninja+path%3A**%2F*.cmake&type=code can be used in the CMakePresets.json? Like https://github.com/StereoKit/sk_gpu/blob/14a354bde53d412743c032e98656877300929075/CMakePresets.json#L92 maybe? I'll have to experiment with this in that "make cmake for wil work" thing.
| } | ||
|
|
||
| #if defined(_M_ARM64) | ||
| const auto g_packageArchitecture = PackageDependencyProcessorArchitectures_Arm64; |
There was a problem hiding this comment.
These are leftovers from the before times, probably not needed anymore.
| "sparse packaging" the app from an external location. | ||
|
|
||
| To loose deploy (directly from an AppxManifest.xml) a sparse package for the sample, | ||
| run the **install.ps1** script after a successful build. |
There was a problem hiding this comment.
Quick question: Where is the install.ps1 script located? Should this step be mentioned here since the cmake project will register the package (with external location flag) post-build using PowerShell? Thanks!
There was a problem hiding this comment.
Drat! Thanks, I'll fix this - there's no install.ps1 needed anymore, the cmakelist autoregisters the output.
Changes include: