t4

EnvDTE not found in VS2012 works in VS2010

半城伤御伤魂 提交于 2019-11-30 23:13:34
问题 I'm using EnvDTE to do some code generation within my T4 Templates. I have the code working correctly in Visual Studio 2010, however I've just started using Visual Studio 2012 and now when I try to run my templates I get the following error Compiling transformation: Metadata file 'EnvDTE.dll' could not be found I don't actually have a reference to EnvDTE in my project as its a Silverlight class library and I wasn't able to add the DLL, however it finds the DLL somehow. I'm not sure what is

Design-time T4 templates in ASP.NET 5 (VS 2015)

扶醉桌前 提交于 2019-11-30 22:42:35
I can't seem to find a way to make T4 templates in VS 2015 RTM, in an ASP.NET 5 (vNext) project. I even installed the T4 toolbox for Visual Studio 2015 extension, but the tt templates are not transformed. The property Custom Tool doesn't appear in the tt file properties, neither can't I find the ' Run Custom Tool ' command. Update The reason I want the T4 templates, is the introduction of the config.json file, and the pluggable configuration system, which is an awesome thing, but with the price of not having the setting properties strongly-typed. I've read this article that explains how to

T4 Templates - suitable for generating C++ code?

爱⌒轻易说出口 提交于 2019-11-30 20:47:09
Are there any issues which might make MS's T4 Template code-generation system unsuitable for generating C++ code? It can generate any text you want, including C++ code. A bit lengthy answer yet I think some might find it interesting I would say T4 is excellent to generate C++ with Some might retort that C++ already has tools to do MetaProgramming with like: The Preprocessor Using the preprocessor and higher-order macros you can achieve somewhat what you can do with T4, but I say there are some pretty convincing benefits of T4: The generated code from T4 is easy to debug and understand

T4 for Sharp Architecture/Northwind Problem

让人想犯罪 __ 提交于 2019-11-30 18:41:24
I have just downloaded sharparchitecture/Northwind and i'm trying to get crud scaffolding to work. I have changed nothing except adding missing reference to this class library. I try to run ScaffoldingGeneratorCommand.tt and I hit following 3 errors. Error 1 Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration file:BaseTemplate.tt Error 2 Compiling transformation: Class, struct, or interface method must have a return type file:BaseTemplate.tt Error 3 Compiling transformation: Type expected file:BaseTemplate.tt Compiler says they occur in the first

T4 code generation: access types in current project

我是研究僧i 提交于 2019-11-30 17:19:53
Using T4 code generation, is it possible to access the types defined in the current project? For example, if I have an interface and I want to delegate its implementation to another class, i.e. interface IDoSomething { public void do_something(); } class DoSomethingImpl : IDoSomething { public void do_something() { // implementation... } } class SomeClass : IDoSomething { IDoSomething m_doSomething = new DoSomethingImpl(); // forward calls to impl object public void do_something() { m_doSomething.do_something(); } } I would like to automate the call-forwarding in SomeClass with code generation

How not to output default T4 generated file?

◇◆丶佛笑我妖孽 提交于 2019-11-30 16:58:07
I am using T4toolbox to generate a bunch of files, let's say my t4 file name is x.t4, but default it generate a x.txt, which has nothing inside, can I tell t4 engine not to do this? Found a trick/hack! <#@ output extension="/" #> or <#@ output extension="\\" #> Visual Studio 2012 neither outputs the default file, nor complains about its inability too much. P.S. I've tried it with T4MultiFile NuGet package , but it should work with T4Toolbox too, I think. Right click on x.t4 in Solution Explorer and click Properties. It will say "TextTemplatingFileGenerator" beside Custom Tool. Delete this. x

T4 code generation: access types in current project

允我心安 提交于 2019-11-30 16:33:11
问题 Using T4 code generation, is it possible to access the types defined in the current project? For example, if I have an interface and I want to delegate its implementation to another class, i.e. interface IDoSomething { public void do_something(); } class DoSomethingImpl : IDoSomething { public void do_something() { // implementation... } } class SomeClass : IDoSomething { IDoSomething m_doSomething = new DoSomethingImpl(); // forward calls to impl object public void do_something() { m

How to Auto Increment Assembly or Assembly File Version, from MSBuild?

强颜欢笑 提交于 2019-11-30 16:00:10
Constraints are: Using Visual Studio 2017. Needs to ultimately be called from a powershell script calling MSBuild. Not sure its relevant, but needs to be able to build the following: asp.net 461 asp.net-core 1.1 and 2.0 assemblies Unsuccessful attempts so far: How to have an auto incrementing version number (Visual Studio)? <- This works when building from VS only. Code Generation in a Build Process -Described as Microsoft's latest document on using "TextTemplating" with MSBuild. States need to copy certain DLLs to build server.. Files are not located where specified in doc, and dont know

How to use a resx resource file in a T4 template

房东的猫 提交于 2019-11-30 15:57:00
I cant figure out how to include the resource file (.resx) in the (.tt) T4 template. I tried so far... Importing the namespace <#@ import namespace="T4TemplateResources.resx" #> Also including the class Nico's solution requires your solution to build. There is another way, without needing to compile your solution by reading the raw resx file. var fileName = "CustomResource.resx"; var filePath = Path.Combine(Path.GetDirectoryName(this.Host.ResolvePath("")), "WindowsFormsApplication1", fileName); var reader = new ResXResourceReader(filePath); var values = reader.Cast<DictionaryEntry>()

How to create multiple output files from a single T4 template using Tangible Editor?

寵の児 提交于 2019-11-30 14:46:33
I tried to follow this tutorial: http://t4-editor.tangible-engineering.com/blog/how-to-generate-multiple-output-files-from-a-single-t4-template.html with visual studio 2015 (.Net 4.5) Sample project with error: http://www.filedropper.com/t4fail I created the Template1.tt with the following source: <#@ include file="TemplateFileManagerV2.1.ttinclude" #> <#@ Assembly Name="System.Core" #> <#@ Assembly Name="System.Windows.Forms" #> <#@ import namespace="System" #> <#@ import namespace="System.IO" #> <#@ import namespace="System.Diagnostics" #> <#@ import namespace="System.Linq" #> <#@ import