t4 "VisualStudioHelper" not found
Asked Answered
M

3

7

I'm trying to do some experiments with generating code from VS2012 projects but I cannot make this piece of t4 code to work

var project = VisualStudioHelper.CurrentProject;

since VisualStudioHelper cannot be found.

What should I install/include in my t4 for making VisualStudioHelper available?

Martinet answered 16/7, 2013 at 20:11 Comment(1)
Found it @ github.com/PombeirP/T4Factories/blob/master/T4Factories.Testbed/…Martinet
R
7

VisualStudioHelper is a custom class from Tangible T4 Editor.

In order to use this class, install Tangible T4 Editor for your Visual Studio and then:

  1. Open Tangible T4 menu in Visual Studio and then click Template Gallery.
  2. Click "Update Now" icon from left-down corner.
  3. Choose from the directory tree: Tangible > Visual Studio CodeModel.
  4. In the files menu, right mouse button on "Walking the Visual Studio Code Model" and choose "Add to Solution..."
  5. Choose "VisualStudioHelper.ttinclude".
  6. In your .tt file refer to VisualStudioHelper as following:

<#@ include file="VisualStudioHelper.ttinclude" #>

Rachitis answered 21/11, 2013 at 21:17 Comment(0)
E
1

What is VisualStudioHelper? This seems to be a custom thing and not something that is built into T4 templating engine. If you need access the current project you may try this:

var dte = (EnvDTE.DTE)((IServiceProvider)Host).GetService(typeof(EnvDTE.DTE));
var project = dte.Solution.FindProjectItem(Host.TemplateFile).ContainingProject;

Don't forget to import the assembly at the top of your T4 template:

<#@ assembly name="EnvDTE" #>
Et answered 16/7, 2013 at 20:42 Comment(2)
Yes, it is a custom tool and I found a version of it @ github.com/PombeirP/T4Factories/blob/master/T4Factories.Testbed/…Martinet
use <#@ template hostspecific="true"#>Samy
I
1

I know VisualStudioHelper from tangible's T4 Editor. It is free and comes with a template gallery providing useful T4 templates you can include in yours e.g. for accessing Visual Studio functionality or project configuration etc.

Maybe you should have a look there.

Edit: The template you should be looking for in the gallery is named "tangible Visual Studio Automation Helper"

Impassioned answered 17/7, 2013 at 6:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.