Skip to content
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

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

japarson
Copy link
Contributor

@japarson japarson commented Mar 17, 2022

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

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 to false.

The current WinUI item templates have ShowByDefault set to true and the solution here it to set them to false.

Demo

The item templates no longer appear in a C# console application:
image

And they still appear in a WinUI app:
image

Work Item

Bug 1433670: WinUI C# templates are available to incompatible projects

@RealTommyKlein
Copy link
Member

Adding Ryan and Evelyn since I don't own the templates and they've worked on them in the past, but LGTM 👍

@japarson
Copy link
Contributor Author

@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?

@evelynwu-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@evelynwu-msft evelynwu-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@japarson japarson merged commit c95cae9 into main Mar 22, 2022
@japarson japarson deleted the user/japarson/1433670 branch March 22, 2022 03:06
evelynwu-msft pushed a commit that referenced this pull request Jun 17, 2022
…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)
evelynwu-msft added a commit that referenced this pull request Jun 17, 2022
…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>
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.

None yet

4 participants