I followed the instructions on creating a custom scaffolder using the T4 Scaffolding package and they worked great. However, in the process I found out that I need to build a lot of reusable components that will be shared across multiple scaffolders and templates.
I know I can build a class library and register it in the GAC to make it accessible to the powershell scripts and T4 templates, but in a team environment, that is not always possible. I'd prefer to check-in the reusable components to source control and make them accessible somehow.
One approach I took was to split the T4 templates into multiple files and include
all of them into the master template.
<#@ include file="Extensions.cs.t4" #>
However, if I define a class in any one of the templates, the class becomes a nested class and therefore can not be static (for example).
Is there a way to build re-usable classes, methods, extensions and make them accessible to custom scaffolders without installing them to the GAC? The T4Scaffolding package has a number of utility functions accessible in the custom scaffolder. How did they do it?
I think I figured it out with the help of this answer. I have to build an assembly with all my shared code. Then, in the Powershell script, I just have to:
import-module "d:\path\to\assembly.dll"
Hope that helps someone. And if anyone has a better idea, please share.