Item templates should pick correct language from project
See original GitHub issueIs your feature request related to a problem? Please describe.
When using a item template inside a F# project, e.g.
dotnet new avalonia.templatedcontrol
I would expect that the option -lang=F#
would not be required but it is.
So it is using the C# version by default when the -lang=F#
was omitted/forgotten.
Describe the solution you’d like.
The solution should be that the templating engine should detect that the item template is added to a project of a known language, when the item template has multiple matching identities with different lang
tags the correct one should be picked.
Additional context
Somewhat related to: #5358
Also I am aware of #2684 but I don’t think that is a solution when e.g. you mostly use C# but only sometimes F#.
Issue Analytics
- State:
- Created 9 months ago
- Reactions:1
- Comments:13 (12 by maintainers)
Top Results From Across the Web
Templates for projects and files - Visual Studio (Windows)
Project and item templates are reusable stubs that give you some basic code and structure to customize for your own purposes. Typically, you ......
Read more >Reusable Project And Item Templates using Visual Studio ...
If a template is identical for multiple languages, providing a value of true in this element will allow the user to choose a...
Read more >Visual Studio Item Templates, Custom Wizards and VSIX ...
Choose correct project types These are all found under the Visual C# > Extensibility category. Yes even though you're creating a C++, F#...
Read more >How to get item templates working in visual studio 2017
On the File menu, click Export Template. Click Item Template, select the project that contains the item, and click Next. Select the item...
Read more >Professional Template Languages - PyCharm
Use this page to select the template language to be used in each of the projects opened in the same window, specify template...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi everyone,
I have contacted the author of the https://github.com/microsoft/VSProjectSystem/blob/master/doc/overview/project_capabilities.md - the document is outdated. F# is added to project capabilities.
The problem is on the templating side - the required information isn’t retrieved during the evaluation phase [ProjectCapabilityConstraint.cs](https://github.com/dotnet/sdk/blob/3eea35e0d77f9a1bc418a364805ff89df818e371/src/Cli/dotnet/commands/dotnet-new/MSBuildEvaluation/ProjectCapabilityConstraint.cs#:~:text=static void-,AddProjectCapabilities,-(HashSet%3C )
We are working on fixing the issue.
After impediment is resolved, the work in template resolution still needs to be done. Picking up correct template language based on project context is not available yet, and template resolution logic should be adjusted to take constraints into account.
Relevant code managing constraints (https://github.com/dotnet/sdk/blob/11f4fee47293e8c9dae5fa902074eb26062d8f99/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/TemplateCommand.cs#L158-L168) happens only when single template is defined.
It should be moved earlier in the invocation cycle, potentially in this method: https://github.com/dotnet/sdk/blob/11f4fee47293e8c9dae5fa902074eb26062d8f99/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.cs#L363-L385
If constraints are satisfied only for single template, it should be preferred. This should fix auto language pick-up.