Reputation: 372
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?
Upvotes: 7
Views: 2433
Reputation: 10350
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:
<#@ include file="VisualStudioHelper.ttinclude" #>
Upvotes: 7
Reputation: 2110
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"
Upvotes: 1
Reputation: 31610
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" #>
Upvotes: 1