-
Notifications
You must be signed in to change notification settings - Fork 413
Update VS Template for C# and WinRT to enable calling AI API by default #5994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates Visual Studio project templates for C# and C++/WinRT desktop applications to enable system AI model capabilities by default, eliminating the need for developers to manually configure manifests for AI API access.
Key Changes:
- Added
systemainamespace declaration andsystemAIModelscapability to all packaged app manifests - Updated
MaxVersionTestedfrom Windows SDK 10.0.19041.0 to 10.0.26226.0 - Applied changes consistently across C# and C++/WinRT templates for unit tests, single-project, and multi-project packaged apps
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dev/VSIX/ProjectTemplates/Desktop/CppWinRT/UnitTestApp/Package-native.appxmanifest | Added systemai namespace and capability to C++/WinRT unit test template; updated target SDK version |
| dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/Package-native.appxmanifest | Added systemai namespace and capability to C++/WinRT single-project template; updated target SDK version |
| dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WapProj/Package-managed.appxmanifest | Added systemai namespace and capability to C++/WinRT packaged app template; updated target SDK version |
| dev/VSIX/ProjectTemplates/Desktop/CSharp/UnitTestApp/Package-managed.appxmanifest | Added systemai namespace and capability to C# unit test template; updated target SDK version |
| dev/VSIX/ProjectTemplates/Desktop/CSharp/SingleProjectPackagedApp/Package-managed.appxmanifest | Added systemai namespace and capability to C# single-project template; updated target SDK version |
| dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WapProj/Package-managed.appxmanifest | Added systemai namespace and capability to C# packaged app template; updated target SDK version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hi Gordon, this PR works for C++ projects, but not C#. The explanation is a bit convoluted... Here are the results of the same experiment with C++ and C# projects and how the final appxmanifest.xml's TargetDeviceFamily is generated: vcxproj: csproj: Several things are going on here. C++ sets TargetPlatformIdentifier to UAP and C# sets it to Windows, which influences the addition of the TargetDeviceFamily downstream. C++ adds Universal TDF (for UAP TPI) and C# adds Desktop TDF (for Windows TPI). In both cases, the MinVersion and MaxVersionTested are replaced with the TPV/TPMV values from the project file. In the case of C++, the existing Windows.Desktop TDF is carried along unchanged. But in the case of C#, the Windows.Desktop TDF is updated, breaking the required MVT of 26226. Note also that due to a bug in the SingleProject extension, these do not work as expected (and documented): All our project templates should only target TDF Windows.Desktop, as that's the only SKU that WinAppSDK supports. We should remove Windows.Universal and update the C++ project templates to set TDI to Desktop to avoid adding Windows.Universal TDF. Also, ideally we'd want the TPV/TPMV substitution behavior, as that's consistent with UWP and wapproj, and provides a single source of truth, and better visibility, for what the developer is targeting and testing. To that end, we would want to prompt the developer to select TPV on project creation, as we do for C++/WinRT templates, via Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard. Unfortunately, we don't have a 26226 SDK publicly available, so we can't yet rely on TPV to propagate to TDF MVT. Related issues: |
Scottj1s
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to address C#, and ideally remove addition of Universal TDF for C++ (see extended discussion)
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
32ff71a to
0bf2783
Compare
Thanks Scott for explain.
Are for the situation my machine haven't installed 26226 SDK, but I still want my app manifest not being overwrite by lower version during build time. Overall, I know the update above is just a "LITTLE" helping not many manual workaround is need, but at least on a machine with latest VS setup and NPU machine should be fine. Hope it helps. |
As mentioned, this actually doesn't work around anything, due to a bug in the single-project code (these properties are simply not implemented by our custom task). The reason C++ works is as I noted - because the single-project code is ignoring the Desktop TDF and modifying the unnecessary Universal TDF instead. I'm ok with taking incremental fixes - just want to make sure we're tracking remaining work. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
* Setting strict mode and error action preference to stop on remaining PS scripts (#5950) * Setting strict mode and error action preference to stop on remaining powershell scripts * Fixing install VCLibs script * Shorten VSIX DisplayName to fit 50 char limit when Experimental prefix is added (#5953) * [main] Update dependencies from microsoft/LiftedIXP/DCPP (#5955) * Update dependencies from https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP build 20251029.6 On relative base path root Microsoft.FrameworkUdk , Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage From Version 2.0.0-experimental-27200.1830.251013-1313.4 -> To Version 2.0.0-experimental-27200.1822.251028-1938.4 Microsoft.WindowsAppSDK.InteractiveExperiences From Version 2.0.1-experimental -> To Version 2.0.2-experimental * Update dependencies from https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP build 20251030.2 On relative base path root Microsoft.FrameworkUdk , Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage From Version 2.0.0-experimental-27200.1830.251013-1313.4 -> To Version 2.0.0-experimental-27200.1835.251029-1735.1 Microsoft.WindowsAppSDK.InteractiveExperiences From Version 2.0.1-experimental -> To Version 2.0.3-experimental --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Disabling flaky push notification test (#5980) * Update bug-report.yaml (#5983) * API Spec: PackageValidator API in PackageManagement.md (#5863) Added documentation for new proposed API for PackageValidation * update issue template for 1.8.3 and 2.0-exp3 (#5993) * [WinAppSDK]: Update resourceManagement.yml (#5988) * Update resourceManagement.yml close issue only if bot comment is posted * fix yml * minor improvements * Fix: getting activity context by reference (#6000) * Fix FileTypeChoices in Storage Pickers to preserve insertion order (#5948) **Description** This is a fix for issue: - #5827 The existing FileTypeChoices property was built on an unordered map, which does not preserve the user-defined order. However, in the FileOpenPicker and FileSavePicker, the FileTypeChoices need to be displayed in the order they were inserted, rather than in a random order. This is important for developers' and end-users' experience because: - Developers expect to see their file type options in the logical order they added them - The first added option is usually the default selection - Maintaining consistent ordering helps end users quickly locate the desired file type Additionaly, the insertion order is respected in the legacy UWP FileSavePicker. **Fix** This is a backward-compatible fix. The goal of this fix is to maintain the existing Map type API contract and its good performance while ensuring that the display order of FileTypeChoices meets expectations. This pull request refactors the implementation of the `FileTypeChoicesMap` to ensure that the insertion order of keys is preserved and provides efficient key lookups. It replaces the previous unordered map-based implementation with the implementation backed by a vector. The update also introduces custom iterator and view classes to support this ordered behavior and modifies related tests to verify the new insertion order. * Revert "Fix: getting activity context by reference (#6000)" (#6004) This reverts commit 2b9dff7. * Migrate net6 to net8 for the Test Sample app (#6003) * Migrate net6 to net8 for the Test Sample app * Rollback change for local test first * Fix also the runtime identifier path * Increasing timeout to try to avoid flakiness (#6010) * Reapply "Fix: getting activity context by reference (#6000)" (#6004) (#6009) This reverts commit 60ea859. * Bugfix: the filter name for FileOpenPicker.FileTypeFilters #6005 * Add localization for NuGet Install Wizard for the VS templates (#5989) * Initial localization commit * Realign and add missing package messages to resources * Update s_resourceManager to _resourceManager * Lazy initialize ResourceManager to make it thread safe * Make Resources not static * Dev in progress, adding error messaging * Resources load without error * Capture localization dev/test state * Undo dev/test configuration and remove wait dialog error check * Resolve conflicting Designer file * Move VSPackage.Designer files back to Common (where resources are) * Update Cpp error message string to include where to find details * Include satellite assemblies * Reset source.extension.vsixmanifests * Remove WizardStringHelper * Clean up null check and spacing * Add copyright headers to VSPackage.Designer.cs files * Passing activity context as argument for deployment methods (#6011) * Passing context as argument for deployment methods * Fixing call for add package methods * Fix: DeploymentManager failing with error package downgrade (#6021) * Dont break on first failure * Adding tests * Movint package removal to cleanup method * Changing GUID to a random one * Changing name from Singleton2 to SingletonHigherVersion * Adding check for registered packages * Fix on verify packages method * Test enhancements suggestion * Fix on verify packages method 2 * Revert "Fix on verify packages method 2" This reverts commit 10060a6. * Revert "Fix on verify packages method" This reverts commit 1c5eb9b. * Bugfix: FileSavePicker.PickSaveFileAsync() should not truncate file when the picked file exists. **Description** This PR is part of the solution of issue - #5976 In `PickSaveFileAsync`, if the picked file exists, user will see a warning prompt re-confirming if the picked file can be overwrite. <img width="1100" height="574" alt="image" src="https://github.com/user-attachments/assets/d956dd69-d4e0-4b11-85e6-b6a79e732418" /> **Then, if user selected "Yes", the FileSavePicker directly truncate the picked file to be empty.** This is not an expected behavior, and it can block some scenarios, such as: - Developers may need to read original content after the file is picked. - Developers may want to add some extra confirmation step before fully overwriting the file (as described in the issue). Additionally, the UWP FileSavePicker won't directly truncate the picked save file in method PickSaveFileAsync(). **Fix** Updating the file creation method to be: - If the picked file doesn't exist, create an empty file. - if the picked file already exist, do nothing, do not truncate it. * add missing samples ref (#5935) * Update dependencies from https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDKAggregator build 2.0.251120.1-experimental (#6025) [main] Update dependencies from microsoft/ProjectReunion/WindowsAppSDKAggregator * Add ManualValidation step for RuntimeCompatibilityChange in servicing builds (#6028) * add a manual validation stage * variable to allow bypassing for experimental/preview * Update dependencies from https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDKAggregator build 2.0.251125.1-experimental (#6038) [main] Update dependencies from microsoft/ProjectReunion/WindowsAppSDKAggregator * [Build] Replace LTSC2019 with LTSC2022 on Foundation repo (#6042) * Update WindowsContainerImage to use ltsc2022 * Update WindowsAppSDK-BuildDevCheck.yml * Add WindowsHostVersion parameter to YAML configuration * Add WindowsHostVersion parameter to YAML file * Add WindowsHostVersion parameter to YAML file * Add WindowsHostVersion parameter to YAML config * Update dependencies from https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDKAggregator build 2.0.251128.1-experimental (#6046) [main] Update dependencies from microsoft/ProjectReunion/WindowsAppSDKAggregator * Update VS Template (#5994) * Localize strings in OutputWindowHelper (#6059) * Localize strings for OutputWindowHelper * Name strings with variables * Add back copyright for VSPackage.Designer.cs files * Keep OutputWindowHelper.cs newlines consistent with WizardImplementation.cs * Remove extra string variables for performance * Making verify package method default to the highest version found (#6026) * Fix on verify packages method * Initializing highest version found to the version being search * Removing match boolean * Using variable instead of winrt call * Using versions to comparisons * Adding singleton lower version package and test * Adding verification for package registering in test * Adding test with multiple singleton versions * Getting Started Documentation: Improving common errors session readability (#6041) * Improving common errors session of getting started doc * Removing extra empty line * Update VSIX resource files to include NuGet wizard strings (#6067) * Update README.md (#6073) * Update dependencies from https://dev.azure.com/microsoft/LiftedIXP/_git/DCPP build 20251216.1 (#6079) On relative base path root Microsoft.FrameworkUdk , Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage From Version 2.0.0-experimental-27200.1835.251029-1735.1 -> To Version 2.0.0-experimental-27200.1845.251215-1020.3 Microsoft.WindowsAppSDK.InteractiveExperiences From Version 2.0.3-experimental -> To Version 2.0.4-experimental Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Test-VisualStudioComponent now detects missing components (#6092) --------- Co-authored-by: Felipe G <guima.felipec@gmail.com> Co-authored-by: Lauren Ciha <laurenciha@microsoft.com> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Roy <59626501+RDMacLachlan@users.noreply.github.com> Co-authored-by: letao-msft <72979394+letao-msft@users.noreply.github.com> Co-authored-by: ssparach <128866445+ssparach@users.noreply.github.com> Co-authored-by: Dinah Xiaoman G <116714259+DinahK-2SO@users.noreply.github.com> Co-authored-by: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> Co-authored-by: alexlamtest <68841560+alexlamtest@users.noreply.github.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Ryan Shepherd <ryansh@microsoft.com>
Background
According to this public doc:

https://learn.microsoft.com/en-us/windows/ai/apis/get-started?tabs=winget%2Cwinui%2Cwinui2
Every dev need to do 3 extra steps before calling AI APIs:
I am not sure if anyone will read this "get-started" step 3 carefully, but at least I don't aware that at all a month ago, and not sure spend me how much time to figure it out on my project.
Fix
In minimal, let's fix the template first. Other Vibe coding Troubleshooting is TBD for existing projects in the world.
This pull request updates several packaged app manifest templates for both C# and C++ desktop projects to support new system AI model capabilities. The changes ensure that new projects created from these templates can declare and use system AI models and are compatible with the most recent Windows features.
Fore sure, there are other circumstance, e.g. what platform SDK VS has, does it run on NPU machine etc which it doesn't mean this change can help for everything, but at least our template update is a good start for less fraction.
Manifest capability and compatibility updates:
systemaiXML namespace and includedsystemai:Capability Name="systemAIModels"in the<Capabilities>section to enable packaged apps to declare usage of system AI models. [1] [2] [3] [4] [5] [6]IgnorableNamespacesattribute to includesystemai, ensuring the new namespace is recognized and ignored where appropriate. [1] [2] [3]MaxVersionTestedforTargetDeviceFamilyentries from10.0.19041.0to10.0.26226.0to target the latest Windows 10 SDK, improving compatibility with newer Windows releases. [1] [2] [3]