dotnet / templating

This repo contains the Template Engine which is used by dotnet new
https://docs.microsoft.com/dotnet/
MIT License
1.61k stars 368 forks source link

Environmental Conditions #846

Closed dansiegel closed 1 year ago

dansiegel commented 7 years ago

It would be fantastic if we could evaluate the developer environment when deciding certain things for a template. Specifically say I want to customize the template based on an IDE extension that the user may have in VS or VS4Mac.

As an example, say the user has MFractor installed in VS4Mac and we're creating on the Mac then I might want to include the ValueConverionAttribute in the template, and since it would be pointless without the extension, if the extension isn't installed in the developer environment, I could exclude the file from the generated project. I'm not sure what the feasibility would be to include that ability from the CLI, but it would be really nice when the tooling is in place to create projects using the templates inside VS/VS4Mac

mlorbetske commented 7 years ago

I think this is interesting, but more of a host concern. When an engine host is configured, an object that provides default values/preferences is passed in. If an extension were to register with the service that set these defaults to indicate its presence & templates were built to check for whatever value the extension is supplementing the defaults collection with, this would already work (in the same way as host conditioning works today - see #839 for how to read these hosting environment defined values)

mlorbetske commented 7 years ago

Let's try this out - adding an interface that we can collect implementations of that can add to the defaults dictionary that's configured for the engine by the host

cc @mhutch

donJoseLuis commented 4 years ago

Need to discuss with the VS integration team

vlada-shubina commented 3 years ago

This issue is quite old, so we would like to know if currently there is a demand on it, please let us know if you are interested in this feature.

The related work for Visual Studio host is tracked in the issue. Related items: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1340438, https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1340439

YuliiaKovalova commented 1 year ago

the issue was moved to VS feedback ticket https://developercommunity.visualstudio.com/t/Environmental-Conditions-for-VS-template/10300748