4

I know I can install nuget packages from templates:

https://learn.microsoft.com/en-us/nuget/visual-studio-extensibility/visual-studio-templates

But I'd like to do the opposite, I'd like to install templates - provided by the nuget package - after the package was installed.

I read I could create a powershell script and run that after the package's been installed. Is that the only way? What are my options here?

Thanks.

eestein
  • 4,914
  • 8
  • 54
  • 93

2 Answers2

0

For .NET Core it can be done using

dotnet new --install <id of your template package>

See docs for the CLI

Alex Buyny
  • 3,047
  • 19
  • 25
  • It doesnt show up after installing. what could be the reason? I tried running as admin as well. It does show/list the templates after that command but i dont see the new template that i try to install. – Ak777 Jun 11 '21 at 04:39
  • Well, for what its worth, after various attempts, it finally worked - by closing all the VS instances, running the admin mode of VS Developer Shell (again). – Ak777 Jun 11 '21 at 05:42
0

I have the same problem, found that:

  1. Dotnet 5.0 can't load templates from my nuget server by id, but dotnet 6.0 can, and puts .nupkg file to %USERPROFILE%.templateengine\packages
  2. VS 2022 and new Rider view these templates.
  3. Dotnet 5.0 can install template by .nupkg local path, and puts it to %USERPROFILE%.templateengine\dotnetcli\v5.0.404\packages
  4. After step 3 you can use templates in Visual Studio 2019, but I also have ide.host.json in .template.config folder https://github.com/sayedihashimi/template-sample#supporting-visual-studio-2019