-
Notifications
You must be signed in to change notification settings - Fork 306
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
Prevent WinUI item templates from showing up in other project types #2289
Conversation
Adding Ryan and Evelyn since I don't own the templates and they've worked on them in the past, but LGTM 👍 |
@evelynwu-msft @ShashankNay I tested the VSIX that has my changes. The results can be found in the PR description. It appears to be working correctly now. How can I run the status checks for this PR? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
…ates ## Problem In a [previous PR](#2289), I attempted to prevent the WinUI C# templates from appearing in projects unrelated to WinUI. To do so, I set the [ShowByDefault](https://docs.microsoft.com/en-us/visualstudio/extensibility/showbydefault-visual-studio-templates?view=vs-2022) property to `false`. When this property is `false`, the decision to show/hide the item templates falls to the [AppliesTo](https://docs.microsoft.com/en-us/visualstudio/extensibility/appliesto-element-visual-studio-templates?view=vs-2022) and [TemplateGroupID](https://docs.microsoft.com/en-us/visualstudio/extensibility/templategroupid-element-visual-studio-templates?view=vs-2022) properties. The C# templates currently hold the value `CSharp + SharedAssetsProject`. However, an examination of the capabilities for a WinUI project reveals that `SharedAssetsProject` is no longer present: ![image](https://user-images.githubusercontent.com/59936622/172943854-a7d108ed-453e-4849-844e-170489d4fca7.png) The C++ templates currently hold no value for `AppliesTo` and `TemplateGroupID`. ## Solution For the C# templates, we can adjust the value for `AppliesTo` to be `CSharp + WindowsAppSdk`. For the C++ templates, we can add the property `AppliesTo` with value `VisualC + WindowsAppSdk`. We can also add the property `TemplateGroupID` with value `WinRT-Native-UAP`, which comes from this table ([link](https://docs.microsoft.com/en-us/visualstudio/extensibility/templategroupid-element-visual-studio-templates?view=vs-2022)): ![image](https://user-images.githubusercontent.com/59936622/172949107-b4be14fc-33d1-466c-9227-2d9db61c1643.png) ## C# ![image](https://user-images.githubusercontent.com/59936622/172935775-e1120116-95bc-4f97-8034-53175686e3a3.png) ## C++ ![image](https://user-images.githubusercontent.com/59936622/172939101-6b791b67-d51d-4ca0-acd5-6014474f03ca.png) ## Work Item microsoft/microsoft-ui-xaml#7148 (cherry picked from commit ea92f45)
…ates (#2641) ## Problem In a [previous PR](#2289), I attempted to prevent the WinUI C# templates from appearing in projects unrelated to WinUI. To do so, I set the [ShowByDefault](https://docs.microsoft.com/en-us/visualstudio/extensibility/showbydefault-visual-studio-templates?view=vs-2022) property to `false`. When this property is `false`, the decision to show/hide the item templates falls to the [AppliesTo](https://docs.microsoft.com/en-us/visualstudio/extensibility/appliesto-element-visual-studio-templates?view=vs-2022) and [TemplateGroupID](https://docs.microsoft.com/en-us/visualstudio/extensibility/templategroupid-element-visual-studio-templates?view=vs-2022) properties. The C# templates currently hold the value `CSharp + SharedAssetsProject`. However, an examination of the capabilities for a WinUI project reveals that `SharedAssetsProject` is no longer present: ![image](https://user-images.githubusercontent.com/59936622/172943854-a7d108ed-453e-4849-844e-170489d4fca7.png) The C++ templates currently hold no value for `AppliesTo` and `TemplateGroupID`. ## Solution For the C# templates, we can adjust the value for `AppliesTo` to be `CSharp + WindowsAppSdk`. For the C++ templates, we can add the property `AppliesTo` with value `VisualC + WindowsAppSdk`. We can also add the property `TemplateGroupID` with value `WinRT-Native-UAP`, which comes from this table ([link](https://docs.microsoft.com/en-us/visualstudio/extensibility/templategroupid-element-visual-studio-templates?view=vs-2022)): ![image](https://user-images.githubusercontent.com/59936622/172949107-b4be14fc-33d1-466c-9227-2d9db61c1643.png) ## C# ![image](https://user-images.githubusercontent.com/59936622/172935775-e1120116-95bc-4f97-8034-53175686e3a3.png) ## C++ ![image](https://user-images.githubusercontent.com/59936622/172939101-6b791b67-d51d-4ca0-acd5-6014474f03ca.png) ## Work Item microsoft/microsoft-ui-xaml#7148 (cherry picked from commit ea92f45) Co-authored-by: James Parsons <japarson@microsoft.com>
Problem
WinUI item templates are appearing in projects where they do not belong. For example, here they are appearing in a C# console application:
![image](https://user-images.githubusercontent.com/59936622/158894587-cbb606b4-58e0-45c7-818d-cda256ca071c.png)
Solution
In the .vstemplate files for each project item, there is a TemplateGroupID property that specifies what kind of project an item templates will show up in. The WinUI item templates correctly set this property. However, there is a ShowByDefault property which specifies that the template will only be displayed under the specified
TemplateGroupID
when set tofalse
.The current WinUI item templates have
ShowByDefault
set totrue
and the solution here it to set them tofalse
.Demo
The item templates no longer appear in a C# console application:
![image](https://user-images.githubusercontent.com/59936622/159384388-65105f1e-6e5f-4cf2-a67e-cde75bc295bb.png)
And they still appear in a WinUI app:
![image](https://user-images.githubusercontent.com/59936622/159384490-b6e7844f-17e1-455e-8cbc-04add9678edf.png)
Work Item
Bug 1433670: WinUI C# templates are available to incompatible projects