t4

Running T4 templates from other T4 template

∥☆過路亽.° 提交于 2019-11-29 14:03:09
问题 does anyone know if it's possible to run T4 template file from another T4 template, inside VS2010 Thank 回答1: Yes, you can. This is how I'm doing it: string templateText = File.ReadAllText(Host.ResolvePath(templateFileName)); Engine engine = new Engine(); string output = engine.ProcessTemplate(templateText, Host); //this is optional - record all output to your file of choice: File.WriteAllText(outputFilePath, output); 回答2: What your probably looking for is http://t4toolbox.codeplex.com/ t4

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

给你一囗甜甜゛ 提交于 2019-11-29 13:53:56
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 TextTransform.exe, is it possible to use this to define $(SolutionDir) ? piers7 Looking through the source

Product of build-time T4 transformation is used only in the next build

若如初见. 提交于 2019-11-29 09:15:13
I have a VS project that contains: a pre-build action running TextTransform on a template.tt to generate generated.cs generated.cs listed as one of the files to compile (i.e. in the list of project files) When I build the project, the pre-build action is executed, generated.cs is re-created, but VS compiles the previous version of generated.cs (which I guess it loaded in memory when the build process started). How to make the build use the new version of generated.cs (i.e. the one generated in the pre-build action)? How to force the build order? Note that the text transformation input is

T4 template to create *multiple* html (for example) output files per table from database schema

為{幸葍}努か 提交于 2019-11-29 08:22:54
问题 I'd like to use some T4 templates to generate html files derived from a sql server (in this case) database schema. For each table in the database, I would like to create 2 files: tableName_List.aspx - would contain the appropriate html to display in an asp.net GridView, with a grid column defined for each db table column tableName_Edit.aspx - would contain the appropriate html to display in an asp.net FormView, with a textbox (for simplicity's sake, for now) for each db table column So, if I

Cannot get T4MVC to work with VS2010 and ASP.NET MVC 2

让人想犯罪 __ 提交于 2019-11-29 06:51:31
I'm trying to add the T4MVC templates to my project, but I'm experiencing some problems. I went to Codeplex and downloaded the latest version of T4MVC , and according to the instructions I just copied the two files T4MVC.tt and T4MVC.Settings.t4 into the root of my web application. Immediately, I got the following errors: From T4MVC.cs (generated file): A namespace cannot directly contain members such as fields or methods From T4MVC.tt (the code generating template): Compiling transformation: The type or namespace name 'ITextTemplatingEngineHost' could not be found (are you missing a using

Calling a class in the same project from T4 template

ぐ巨炮叔叔 提交于 2019-11-29 04:28:06
I'm attempting to create some scaffolding for CRUD classes and would like use T4 to assist in building these classes. I'm just getting started and having an issue calling a class that lives in the same project. Ex: <#@ import namespace="System.Collections.Generic" #> <#@ template language="C#" #> <#@ output extension=".cs" #> <#@ include file="T4Toolbox.tt" #> using System; using System.Data; using System.Data.Linq; using System.Collections.Generic; namespace TTFileGenerator { <#var entityName = "TEST";#> public class <#=entityName#> { <# MyClass myClass = new MyClass(); List<string> something

Does VS 2010 Express edition support T4 preprocessed templates?

限于喜欢 提交于 2019-11-29 03:50:44
Just installed 2010 Express Edition and I cannot see Preprocess t4 template as an option. Is it not supported in 2010 Express? Unfortunately the item templates got a little misconfigured in our setup program for VS Express editions and are not in the right place on disk, so don't show up in the Add New Item dialog. In VS 2010 Express Editions, we do support T4 templates of both regular and preprocessed kinds, however you'll have to set them up yourself. If you add a regular text file, then rename its extension to '.tt", it should automatically get the regular T4 custom tool set up in the

MvcTextTemplateHost not found

被刻印的时光 ゝ 提交于 2019-11-29 03:13:33
I'm trying to use the T4 templates in my MVC project. This screencast suggests just copying the existing T4 templates for MVC into your solution and going from there. However when I try to compile I get this error: Error 1 Compiling transformation: The type or namespace name 'MvcTextTemplateHost' could not be found (are you missing a using directive or an assembly reference?) I have no idea what assembly this might live in, and google isn't being much help with it. Does anyone know what assembly I should reference? For each template right click, select Properties and clear the Custom Tool

T4 template for NHibernate? - not Fluent NHibernate

最后都变了- 提交于 2019-11-29 02:15:08
Wondering if anyone knows of a set of T4 templates for generating C# POCO classes and also mapping XML files for NHibernate from a set of tables in a database. I saw that David Hayden has created T4 for generating FluentNH code based upon a DBML model, but I'm not quite ready to use FluentNH yet as there isn't even an official release yet (although I love the idea). Anyone know of any T4 templates for using plain NHibernate? May not be the answer you are looking for, but I spent a good amount of time a couple months ago looking everywhere for the same thing. I couldn't find any, though. Not

How to use a dynamic connection string using a Model First approach but still use the data model in the EDMX?

非 Y 不嫁゛ 提交于 2019-11-29 01:42:20
问题 I have created an EDMX using EF 5 with the Model First approach, i.e. I started with a blank designer and modeled my entities. Now I want to be able to use this model defined in the EDMX but supply runtime SQL Server connection strings without modyfing the config file. I know how to pass a connection string to the DbContext but the issue is locating the metadata for the mappings within the assembly. For example, my EDMX has this connection string in the app.config <add name="MesSystemEntities