Skip to content

Enable item templates for metapackage and WinUI projects#6604

Open
lauren-ciha wants to merge 3 commits into
mainfrom
user/laurenciha/investigate-missing-item-templates-without-metapackage
Open

Enable item templates for metapackage and WinUI projects#6604
lauren-ciha wants to merge 3 commits into
mainfrom
user/laurenciha/investigate-missing-item-templates-without-metapackage

Conversation

@lauren-ciha

Copy link
Copy Markdown
Member

Resolves #5923, which reported that the Add New Item menu omitted the WinUI templates when the WinUI PackageReference was included without the Windows App SDK metapackage.

Before, the item templates' .vstemplate AppliesTo property only had WindowsAppSDK, which is only emitted by the metapackage. Adding WinUI allows the item templates to appear when either the metapackage Microsoft.WindowsAppSDK or WinUI package Microsoft.WindowsAppSDK.WinUI is included in the project.

Notes:

  • The build assets for either package need to be included in order to see the item templates. Setting IncludeAssets=None in the PackageReference will omit the item templates.
  • If adding Windows App SDK or WinUI to an existing project, close and reopen VS to see the WinUI templates in the New Item menu

Validation:

  • Fetch and build the branch with .\dev\Templates\VSIX\build-local-VSIX-packagebuild-install-localdev-vsix.ps1.
  • Create a new C# template with the local dev templates
  • In the {AppName}.csproj, switch <PackageReference Include="Microsoft.WindowsAppSDK" Version="*" /> to Microsoft.WindowsAppSDK.WinUI.
  • Close VS
  • Reopen the same project in VS
  • Click "Add New Item" (Ctrl+Shift+A)

I ran the same validation on a standalone VSIX.


A microsoft employee must use /azp run to validate using the pipelines below.

WARNING:
Comments made by azure-pipelines bot maybe inaccurate.
Please see pipeline link to verify that the build is being ran.

For status checks on the main branch, please use TransportPackage-Foundation-PR
(https://microsoft.visualstudio.com/ProjectReunion/_build?definitionId=81063&_a=summary)
and run the build against your PR branch with the default parameters.

lauren-ciha and others added 3 commits July 9, 2026 11:42
VS 'Add New Item' item templates gated visibility on the 'WindowsAppSDK' project capability, which is only contributed by the meta Microsoft.WindowsAppSDK package. Projects referencing only the split Microsoft.WindowsAppSDK.WinUI package get the 'WinUI' capability instead, so the templates never appeared.

Relax AppliesTo in all 13 item templates to accept either capability: 'CSharp + (WindowsAppSDK | WinUI)' and 'VisualC + (WindowsAppSDK | WinUI)'. Parentheses are required because '+'/'&' (AND) bind tighter than '|' (OR).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lauren-ciha

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses missing WinUI item templates in Visual Studio when a project references the WinUI split package (Microsoft.WindowsAppSDK.WinUI) instead of the Windows App SDK metapackage, by broadening template AppliesTo expressions to match either the WindowsAppSDK or WinUI project capability.

Changes:

  • Updated multiple item template .vstemplate files to use AppliesTo expressions that include (WindowsAppSDK | WinUI) for both C# and C++/WinRT templates.
  • Removed several wizard-related string resources from the C# VSIX VSPackage.resx.
  • Added a clarifying comment in the shared wizard implementation.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dev/Templates/VSIX/Shared/WizardImplementation.cs Adds a comment describing when NuGet installation is triggered during template generation.
dev/Templates/VSIX/Extension/Cs/Common/VSPackage.resx Removes wizard-related string resources (1044–1054) from the C# extension’s neutral resources.
dev/Templates/Source/ItemTemplates/Neutral/CSharp/UserControl/WinUI.Neutral.Cs.UserControl.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CSharp/TemplatedControl/WinUI.Neutral.Cs.TemplatedControl.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CSharp/Resw/WinUI.Neutral.Cs.Resw.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CSharp/ResourceDictionary/WinUI.Neutral.Cs.ResourceDictionary.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CSharp/ContentDialog/WinUI.Neutral.Cs.ContentDialog.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CSharp/BlankPage/WinUI.Neutral.Cs.BlankPage.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CppWinRT/UserControl/WinUI.Neutral.CppWinRT.UserControl.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CppWinRT/TemplatedControl/WinUI.Neutral.CppWinRT.TemplatedControl.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CppWinRT/Resw/WinUI.Neutral.CppWinRT.Resw.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CppWinRT/ResourceDictionary/WinUI.Neutral.CppWinRT.ResourceDictionary.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Neutral/CppWinRT/BlankPage/WinUI.Neutral.CppWinRT.BlankPage.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Desktop/CSharp/BlankWindow/WinUI.Desktop.Cs.BlankWindow.vstemplate Broadens AppliesTo to include WinUI capability.
dev/Templates/Source/ItemTemplates/Desktop/CppWinRT/BlankWindow/WinUI.Desktop.CppWinRT.BlankWindow.vstemplate Broadens AppliesTo to include WinUI capability.

Comment on lines 219 to 224
<data name="1043" xml:space="preserve">
<value>A project template that creates MSIX packages containing WinUI applications for side-loading or distribution via the Microsoft Store.</value>
</data>
<data name="1044" xml:space="preserve">
<value>Installing NuGet packages into project...</value>
</data>
<data name="1045" xml:space="preserve">
<value>Operation in progress...</value>
</data>
<data name="1046" xml:space="preserve">
<value>Missing Package Reference(s)</value>
</data>
<data name="1047" xml:space="preserve">
<value>Unable to add references to the following packages for {0}: {1}. Please add package references before building.</value>
</data>
<data name="1048" xml:space="preserve">
<value>[{0}] Unable to add references to the following packages: {1}. This is an environment error. Please add package references before building the project.</value>
</data>
<data name="1049" xml:space="preserve">
<value>Manage NuGet Packages</value>
</data>
<data name="1050" xml:space="preserve">
<value>See error details</value>
</data>
<data name="1051" xml:space="preserve">
<value>Missing Package References for {0}:</value>
</data>
<data name="1052" xml:space="preserve">
<value>Please manually add package references before building.</value>
</data>
<data name="1053" xml:space="preserve">
<value>General</value>
</data>
<data name="1054" xml:space="preserve">
<value>No output information available.</value>
</data>
<data name="1055" xml:space="preserve">
<value>WinUI TabView App</value>
</data>
Comment thread dev/Templates/VSIX/Shared/WizardImplementation.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using the independent WinUI 3 package, Visual Studio cannot find the WinUI template

2 participants