Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Powershell script to be used with Nuget packages. On install it programatically discovers all T4 Text Template Files in the Nuget Package and modifies their addition to the Project to exclude the Generator and LastGenOutput tags.
param($installPath, $toolsPath, $package, $project)
#Get all of the T4 files in the package extension .tt
$files = $package.GetFiles() | Where-Object {$_.EffectivePath -match "tt$"}
foreach ($file in $files)
$fileName = $file.EffectivePath
$ProjectItem = $project.ProjectItems | Where-Object {$_.Name -eq $fileName}
#Set CustomTool to empty not TextTemplatingFileGenerator
$CustomTool = $ProjectItem.Properties | where-object {$_.Name -eq "CustomTool"}
$CustomTool.Value = ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment