At the .net open space in Leipzig I promised to write down the experience in migrating T4 Text Templates from VS2008 to VS2010 Beta 2. And here we go…

In order to migrate you will need to do the following

Issue1:  C# Version is now 4 by default

Old:

<#@ template language="C#v3.5" #>

New:

<#@ template language="C#" #>

Issue2:  ModelingTextTransformation not any longer found

Old:

<#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>

New: (You need an assembly reference eventually)

<#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>
<#@ assembly name="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TextTemplating.Modeling.10.0.dll"#>

 

Issue: EnvDTE ProgID has changed from 9.0 to 10.0

Old:

<#@ assembly name=”envdte” #>
<# EnvDTE.DTE theDTE = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.9.0"); #>

New:

Note it is always better to get EnvDTE from the Template host – this requires hostSpecific to be true

<#@ template hostSpecific="true" #>
<#@ assembly name=”envdte” #>

Now you can get the envdte this way

<#  IServiceProvider hostServiceProvider = (IServiceProvider)host;
var theDTE = (EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE)); #>

Issue: Some other DSL DLL Names changed - here are new names

In GAC (do not use “.dll” in <#assembly#> reference)

Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0
Microsoft.VisualStudio.Modeling.Sdk.10.0

Not in GAC (use. dll when referencing them)

Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll
Microsoft.VisualStudio.TextTemplating.Modeling.10.0.dll
Microsoft.VisualStudio.TextTemplating.VSHost.10.0.dll 

You find them here

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\

or here

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\

or in the SDK Install Dir

I think these are the most common issues. I will add if i find more.

Happy generating

Tim