I just spent about 2 hours troubleshooting why my T4 Generator wasn’t using the correct version of the DLL. It turns out the latest version of Visual Studio insalled a newer version of ‘Microsoft.SqlServer.Smo’.
My template was originally using the following code:
<#@ assembly name="Microsoft.SqlServer.Smo" #>
I then tried using the full path to ensure it was not pulling from the Global Assembly Cache this seems to have resolved the issue. I now can say with confidence the T4 template will now be shielded from any changes to the GAC made by Visual Studio or SSMS.
<#@ assembly name="$(SolutionDir)CodeGeneration\bin\Debug\Microsoft.SqlServer.Smo.dll" #>
Hopefully, somebody will find this post and save some time. Did I mention I hate the GAC?