Struggling to Get Anything to Work

Jul 21, 2010 at 10:44 AM

In my first scenarion I tried to be adventurous and reflect over a class - but it would not recognise the class which resides in the same assembly as my T4 template and scripts. I referenced the file, namespace and assembly - all without any luck.

So I go back to basics and coy oleg's example character for character from this blog post http://www.olegsych.com/2008/09/t4-tutorial-creating-reusable-code-generation-templates/#comment-3187.

Now the problem is this:

Error    7    Compiling transformation: The type 'Microsoft.SqlServer.Management.Sdk.Sfc.IDmfFacet' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.    c:\Users\nick\Documents\NonProj_Apps\t4 t2\t4 t2\DeleteProcedureTemplate.tt    12    9    t4 t2

So I reference ths missing .dll - and every other .dll in the SQL folder. But the problem still persists.

And now I sit here a broken man, questioning whether to continue with life. After being on the cusp of T4 greatness, I sit surrounded by emptiness and loneliness.

Please help my wounded soul.

Jul 21, 2010 at 10:56 AM

I've tried stripping out all the code and just doing a call to writeline in my template and RenerTransform() in the script. Here's the code

 

<#@ template language="C#" hostspecific="True" #>
<#@ output extension="txt" #>
<#@ include file="T4Toolbox.tt" #>
<#@ include file="DeleteProcedureTemplate.tt" #>
<#
    DeleteProcedureTemplate template = new DeleteProcedureTemplate();
    template.TransformText();
#>

 

<#+
public class DeleteProcedureTemplate : Template
{

    public override string TransformText()
    {
        Console.WriteLine("cheese");
        return this.GenerationEnvironment.ToString();
    }
}
#>

 

Surely this should work?......Well, maybe this is the problem:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3253: The referenced assembly "Microsoft.SqlServer.ScriptTask, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
  t4 t2 -> C:\Users\nick\Documents\NonProj_Apps\t4 t2\t4 t2\bin\Debug\t4 t2.exe

I'm getting that message when I build. Does your toolbox have a problem with .NET 4.0 or is this message saying something else to me?

 

Thanks

 

Jul 21, 2010 at 11:01 AM

So I'm targetting .NET 3.5 and now I get this....arghhhhhhhhhhh!

 No way to resolve conflict between "EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
  Consider app.config remapping of assembly "EnvDTE, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "7.0.3300.0" [] to Version "8.0.0.0" [c:\Program Files\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\EnvDTE.dll] to solve conflict and get rid of warning.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
  t4 t2 -> C:\Users\nick\Documents\NonProj_Apps\t4 t2\t4 t2\bin\Debug\t4 t2.exe

 

Coordinator
Jul 21, 2010 at 11:29 AM

Nick,

This error is due to some new dependencies in the SMO implementation in SQL Server R2. This has nothing to do with T4 or the T4 Toolbox. You simply need to add the following assembly directive to the template:

<#@ assembly name="Microsoft.SqlServer.Management.Sdk.Sfc" #>

Referencing assemblies in the underlying Visual Studio project does not resolve T4 errors.

Oleg

Jul 21, 2010 at 12:19 PM

Thanks Oleg,

My mission to bring peace to the world using the wonders of your T4 Toolbox is back on.

I owe you one.,