Search code examples
.netgithub-actionsvisual-studio-2022project-template

Use custom .NET Core templates in Visual Studio 2022


I've created a bare-bone git-repository with a Github Action which builds and publishes a nuget package containing 2 .NET templates. These templates can be installed using

dotnet new --install MintPlayer.AspNetCore.IdentityServer.Templates

Then you can create a new project using

dotnet new id-provider

But these templates aren't available from Visual Studio 2022, even though I've added the .template.config/ide.host.json file:

{
  "$schema": "http://json.schemastore.org/vs-2017.3.host",
  "order": 0,
  "icon": "music_note_64.png",
  "symbolInfo": [
  ]
}

What do I need to do to get them into Visual Studio 2022 too? Do I need a VSIX package, like in this example? Is it necessary to upload a VSIX to the Visual Studio Marketplace?

Use .NET Templates in Visual Studio


Solution

  • Ok so apparently I was missing the following in the template.json file

    "tags": {
      "language": "C#",
      "type": "project"
    }
    

    And it seems that you also have to take the following into account:

    Name Description
    groupIdentity The ID of the group this template belongs to. When combined with the tagssection, this allows multiple templates to be displayed as one, with the the decision for which one to use being presented as a choice in each one of the pivot categories (keys)

    So if you want them in Visual Studio as 2 separate templates, you need different values for groupIdentity