I think the trick is to do the scaffolding from the Templates project and pass in the name of the project you want to generate into e.g.
T4Scaffolding.Scaffolder(Description = "Creates a model entity")][CmdletBinding()]
param(
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)][string]$EntityName,
[string]$ProjectName,
[string]$CodeLanguage,
[string[]]$TemplateFolders,
[switch]$Force = $false
)
# Find the code project, or abort
$project = Get-Project ( $ProjectName) -ErrorAction SilentlyContinue
if (!$project) { throw "Cannot find code project corresponding to solution '$ProjectName'" }
$entityFile = $EntityName
Add-ProjectItemViaTemplate $entityFile -Template EntityTemplate `
-Model @{ Namespace = $namespace; EntityName = $EntityName; MappingName = $MappingName } `
-SuccessMessage "Added Model non-gen output at {0}" `
-TemplateFolders $TemplateFolders -Project $ProjectName -CodeLanguage $CodeLanguage -Force:$false
You must pass a string to the -Project argument in Add-ProjectItemViaTemplates not a project object
If you already know the projects that the various scaffolders need to apply to, then you can set a default value for ProjectName in the scaffolder.
There's some examples of this in the MvcScaffolding package.