t4

Get argument value from TextTransform.exe into the template

安稳与你 提交于 2019-12-19 02:47:25
问题 I can't found some example how can I use argument -a when I use TextTransform.exe to generate code from templates. In MSDN is following description for argument -a: "Specifies a parameter that a directive processor can query for as a name/value pair. The directive processor and identifier are optional. This allows parameters to be specified for any directive processor or any instance of a particular directive processor." I need some set of arguments like connection string and so on in my

T4 for Sharp Architecture/Northwind Problem

。_饼干妹妹 提交于 2019-12-18 19:45:11
问题 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

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

泪湿孤枕 提交于 2019-12-18 17:48:11
问题 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

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

 ̄綄美尐妖づ 提交于 2019-12-18 16:52:35
问题 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

How to add a dependency to a arbitrary file to a T4 template?

十年热恋 提交于 2019-12-18 15:53:22
问题 I have a T4 template that generates classes from an xml file. How can I add a dependency between the xml file and the template file so that when the xml file is modified the template is rerun automatically without choosing "Run custom tool" from the context menu? 回答1: I don't believe T4 supports automatic template transformation based on an external dependency. I agree with Marc - if you only have one external file, you could create a custom "custom tool" for your XML file or simply use

How do you use .net Reflection with T4?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 12:55:13
问题 I have a c# project which includes a Text Template. I would like this template to generate some SQL based on reflecting against the C# classes in the project. How does one access the current project's contents using T4? Is it possible, and if so, is Reflection available, or is it access to just the raw source that must then be parsed? Thanks in advance! 回答1: How does one access the current project's contents using T4? One way is to use the EnvDTE COM component. Googling T4 and EnvDTE should

T4 template and run-time parameters

六眼飞鱼酱① 提交于 2019-12-18 11:57:35
问题 I am building a plug-in in VS 2010 and I get stuck at the T4 generation. Right now I have implemented (like MSDN suggests) a custom T4 host to generate my T4 results and I use it in this way: const string content = @"c:\Simple.tt"; var engine = new Engine(); var host = new MyTemplateHost(); var result = engine.ProcessTemplate(File.ReadAllText(content), host); foreach (CompilerError error in host.Errors) { Console.WriteLine(error.ErrorText); } This works until I pass a parameter in the

T4MVC Error - T4 file is blocked or in a non trusted zone

℡╲_俬逩灬. 提交于 2019-12-18 10:52:13
问题 I am running Visual Studio 2010 on a Windows 7 virtual machine inside of Parallels Desktop 8 on a Mac Book Pro. I'm trying to incorporate T4MVC into a new MVC4 project. I installed the T4MVC package from Nuget and immediately started getting this error... Failed to resolve include text for file:The path '\psf\Home...\T4MVC.tt.hooks.t4' must be either local to this computer or part of your trusted zone. If you have downloaded this template, you may need to 'Unblock' it using the properties

How do I pass a string parameter to a t4 template

倖福魔咒の 提交于 2019-12-18 10:44:31
问题 Hi I am trying to find a way to pass a normal string as a parameter to a text template. This is my Template code, if someone could tell me what I would need to write in c# to pass my parameters and create the class file. That would be very helpful, Thanks. <#@ template debug="false" hostspecific="true" language="C#" #> <#@ output extension=".cs" #> <#@ assembly name="System.Xml" #> <#@ assembly name="EnvDTE" #> <#@ import namespace="System.Xml" #> <#@ import namespace="System.Collections

Using $(SolutionDir) when running template via TextTransform.exe

余生长醉 提交于 2019-12-18 05:57:16
问题 I'm trying to get our T4 templates to run at build time, without adding dependencies on the Visual Studio Modeling SDK. I've successfully used a variant of the batch file shown here, but I now have a problem in that my .tt files use the $(SolutionDir) variable to reference other projects (and thus are now not compiling). What is the best way to handle this? What have other people done? (Hard-coding absolute paths is not an option) EDIT: I see there's the -a argument that can be passed to