Skip to content

[Templates] Consider publishing WPF templates in package per TFM  #5117

Open
@vlada-shubina

Description

@vlada-shubina

Related conversation: dotnet/docs#25603

Recently there was a conversation on how to target older frameworks in the templates, which again revealed that .NET templates in SDK are following 2 different approaches for distribution:

Common project and web/SPA project templates

The templates are shipped in separate packages: one package per TFM.
Examples:

  • microsoft.dotnet.common.projecttemplates.5.0 - the project common templates for .NET 5.0 (enables --framework net5.0 in dotnet new)
  • microsoft.dotnet.web.projecttemplates.3.1 - the project common templates for .NET 3.1 (enables --framework netcoreapp3.1 in dotnet new)

Different TFM packages share same group identity, so installing several packages (for example microsoft.dotnet.web.projecttemplates.6.0, microsoft.dotnet.web.projecttemplates.5.0, microsoft.dotnet.web.projecttemplates.3.1) doesn't lead to multiple templates being shown, but additional --framework option to be available.
For example, if the templates above are installed the user has 3 options for --framework: net6.0, net5.0, netcoreapp3.1.

When certain SDK version is installed, it installs the template for corresponding TFM:

  • if SDK 6.0 is installed, it installs microsoft.dotnet.common.projecttemplates.6.0 and microsoft.dotnet.web.projecttemplates.6.0, so user can only target net6.0
  • if user additionally installs SDK 5.0, it installs microsoft.dotnet.common.projecttemplates.5.0 and microsoft.dotnet.web.projecttemplates.5.0, so now user can target net6.0 and net5.0 via --framework option when in .NET 6, and so on.

Additionally, all the template packs are available on NuGet.org, so as example if the user needs to use netcoreapp3.0, he may install microsoft.dotnet.common.projecttemplates.3.0 manually and use it in dotnet new.

WPF, WinForms

The templates are shipped in single package with all supported TFMs listed in --framework parameter
Example:

  • microsoft.dotnet.wpf.projecttemplates for 5.0 has net5.0, netcoreapp3.1 and netcoreapp3.0 frameworks available.
  • microsoft.dotnet.wpf.projecttemplates for 6.0 has net6.0, net5.0, netcoreapp3.1 and netcoreapp3.0 frameworks available.

Different versions have same template identities, but different priority (precedence) - this allows later template version overwrite previous version.

This is different from behavior above:
When certain SDK version is installed, it installs the template for corresponding version:

  • if SDK 6.0 is installed, it installs microsoft.dotnet.wpf.projecttemplates for 6.0, so user can target net6.0, net5.0, netcoreapp3.1 and netcoreapp3.0 frameworks without installing corresponding SDKs.
  • if user additionally installs SDK 5.0, it installs microsoft.dotnet.wpf.projecttemplates for 5.0 which won't be used for SDK 6.0 because newer version is available; however will be used if the user runs dotnet new from SDK 5.0.

Additionally WPF and WinForms templates are not available on NuGet.org, however they seems to contain all supported TFMs, so that it should not be a problem, rather inconsistency.

Ideally it would be great to align the behavior across all the templates, so the users have same experience with SDK built-in templates.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions