templating icon indicating copy to clipboard operation
templating copied to clipboard

Need doc or any info on how to make my templates available for all users on PC

Open smalgin-esri opened this issue 3 years ago • 3 comments

I looked around and could not find any documentation nor issue asking for this:

  • Our SDK installs several dotnet templates. We used to do this with VSIX but new way is much easier.

We generate nuget with templates and everything works fine.

But there's one big 'but': by default, dotnet new --install mytemplates.nuget will only install templates into a .templateengine folder in my user account.

What is appropriate way to install templates for all users on a PC? If there's none then we'll probably get back to making VSIX...

smalgin-esri avatar Jan 19 '22 23:01 smalgin-esri

I checked - simply dropping nupkg into Program Files/dotnet/templates/6.0.0 works... how safe is this?

smalgin-esri avatar Jan 19 '22 23:01 smalgin-esri

Hi @smalgin-esri, Thank you very much for the issue. There is another issue which will help you by allowing you to specify the templates folder on your machine. Please track https://github.com/dotnet/templating/issues/1650. I will keep this one open to make sure we test it properly after the other issue is fixed.

bekir-ozturk avatar Jan 24 '22 12:01 bekir-ozturk

The fix for #1650 (providing custom path for .templateengine folder) doesn't change the fact that there's a default location for ALL users, so this issue is still relevant by itself. As a custom template provider we used to have new templates available for all users via VSIX. Having functional parity (or a clearly documented explanation about placing template nugets into Program Files/dotnet/templates) will be very welcome.

smalgin-esri avatar Jan 25 '22 01:01 smalgin-esri

Close with Low Priority

YuliiaKovalova avatar Mar 06 '23 09:03 YuliiaKovalova

Note: People, just stay with the VSIX, this package system is not going anywhere.

smalgin-esri avatar Mar 06 '23 20:03 smalgin-esri

Too bad this issue being closed without a workaround at least. Using VSIX does not work for us because it is IDE-dependent.

I checked - simply dropping nupkg into Program Files/dotnet/templates/6.0.0 works... how safe is this?

As far as I found out by trying: Dropping the package into any of the pre-installes subfolders of Program Files/dotnet/templates/ works. However dopping it into a new subfolder does not work. There is another template-folder named template-packs but dropping into this one does not work either.

So what is the official way or workaround to provide / install a template for all users? (There are scenarios where you have to keep the users profile small. So installing common templates into each users profile is bad.)

How to configure the template engine to probe for an extra folder, common for all users?

EO3-Kopf avatar Aug 21 '23 12:08 EO3-Kopf

@smalgin-esri, I found something that might help also in your case: You can create a new folder in Program Files/dotnet/templates/. If it starts with a numerical value (e.g. 6.MyCompany) the template engine will recognize this folder.

EO3-Kopf avatar Aug 21 '23 14:08 EO3-Kopf

Simply speaking, the engine wasn't designed for this and currently doesn't support it. As a workaround, the engine will allow you into install/use templates that have been installed from a NuGet feed that is globally available on that system (configured via NuGet.config).

baronfel avatar Aug 21 '23 15:08 baronfel

@baronfel, thanks for this clear statement.

However templates from the NuGet feed will get installed in the users profile. And as I mentioned above there are scenarios where must not bloat the user profile...

EO3-Kopf avatar Aug 21 '23 15:08 EO3-Kopf