t4

T4 Template containing XML results in parse errors

北慕城南 提交于 2019-12-05 14:01:32
I have created T4 Templates for the config files of my web and windows projects. I can successfully generate master web.config, and all configs for other environments, i.e. web.ci.config, etc..However, I could not get rid of the errors on my master tt files, such as : Character '#', hexadecimal value 0x23 is illegal in an XML name. Character '<', hexadecimal value 0x3c is illegal in XML attribute values. Unexpected XML declaration. The XML declaration must be the first node in the document and no white space characters are allowed to appear before it. I should be missing a xml schema or a

Entity Framework 5 stopped running T4 templates files on save

喜欢而已 提交于 2019-12-05 13:08:52
At work we just upgraded to Entity Framework 5. Our EDMX file now has a couple other nodes beneath it: EntityContainer.Context.tt which contains the generated DbContext object and EntityContainer.tt which contains the entities themselves. For a short period, adding an entity in EF was automatically regenerating the tt (T4 Templates) when we would save the EDMX file. Now all of a sudden we have to right-click the T4 templates and select "Run Custom Tool" to get them to regenerate the .cs files for the context or entities. Any ideas how this might have happened? Update In the EDMX the property

How to disable #line directives being written to the T4 generation output file

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 12:50:28
问题 I have encountered a small problem with my T4 code generation. I have broken my T4 templates up into separate files and placed them in various directories, I have done this so parts of my code generation may be re-used in multiple projects, e.g. model generation, repository generation and service generation all include a core EntityGeneration.tt file. Unfortunately, when TextTemplating resolves my nested includes, it builds up a long #line pre-processor directive in its generated .cs file,

T4 -> C# class to Knockout View Model in Typescript [closed]

99封情书 提交于 2019-12-05 07:46:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm looking for some sort of T4 or similar way to take C# classes and generate both the interfaces for the data that will come across the wire AND the view models in a strongly typed fashion. I found typelite which works well for interfaces, but I'm looking for something that will handle the viewmodels too (or

How to add new Scaffold used in Visual Studio 2013 Scaffolding?

拜拜、爱过 提交于 2019-12-05 06:36:43
Is there a way to add a new Scaffold or override the Scaffolding functionality used in the new Visual Studio 2013 Scaffolding? The only documentation I can find on the internet is how to override the T4 templates using the CodeTemplates folder. I want to add a new Scaffold to the list when Add... > New Scaffold Item... It looks like in Visual Studio 2013 this has been rolled into a library (Microsoft.AspNet.Scaffolding.Mvc.5.0.dll) and registered in the GAC or as a VS Extension. http://weblogs.asp.net/imranbaloch/archive/2013/09/15/customizing-the-asp-net-mvc-5-web-api-2-scaffolding-templates

Run T4 text template programmatically

て烟熏妆下的殇ゞ 提交于 2019-12-05 06:24:50
Is there a way to programmatically run T4 text templates from code? I'm making a custom domain specific language and I would like the related text templates to run every time the user saves. Currently, this is what I do in the DSL model: protected override void OnDocumentSaved(EventArgs e) { IVsCommandWindow commandWindow = (IVsCommandWindow)this.ServiceProvider.GetService(typeof(IVsCommandWindow)); if (commandWindow != null) { commandWindow.ExecuteCommand("TextTransformation.TransformAllTemplates"); } base.OnDocumentSaved(e); } This works, but it has a really annoying side-effect. If the

Visual Studio 2012 T4 templates generating XML gives error

Deadly 提交于 2019-12-05 05:52:11
I'm using visual studio 2012 to generate XML from a T4 template. The top of the template looks like <#@ template language="VBv4" hostspecific="True" debug="True" #> <#@ output extension="wmef" #> <?xml version="1.0" encoding="utf-8" standalone="yes"?> The T4 template correctly generates the XML. This is no problem. However visual studio is getting confused and it additionally tries to process the template itself as XML and reports build errors saying the XML is ill formed which of course it is because it is a template for XML and not the actual XML. When I first edit the .tt file everything is

how to generate a Custom Class via t4?

我的未来我决定 提交于 2019-12-05 04:41:29
问题 I am trying to generate the below code via T4. using System; using MyDAL; namspace Test { // Select... public partial class MyCustomer { public int id { get ;set;} public string name { get ;set;} public string surname { get ;set;} public MyCustomer() { } public List<Customer> GetById(int id) { // do something... } } // Delete,Update,Save public partial class MyCustomer { public bool Save(new MyCustomer) { // do something... } public bool delete(int id) { // do something... } public bool

T4 Preprocessed Template Debugging Not Working - Visual Studio 2010 RTM

社会主义新天地 提交于 2019-12-05 04:14:31
I am attempting to debug a preprocessed T4 template and I am not able to step into the class created by running the preprocessed template. I am able to create an instance of the class but as soon as I try to step into while debugging, a new window pops up that says No source available. There is no source code available for the current location. My understanding was that preprocessed templates could be debugged just like a normal c# class, is this not correct? Is there anything in particular that you need to do to be able to step into the class defined by a preprocessed template? Here is a very

Running TextTransform.exe (T4) on a build server

夙愿已清 提交于 2019-12-05 04:14:10
I am trying to setup a process where my T4 templates will be transformed on the build server (Visual Studio is not installed there). I've read all online references, but could not get a clear source that shows how to do this. Specifically, here's the 2 issues i've encountered: TextTransform.exe throws an error about missing DLL: C:\TeamCity\buildAgent\work\AppSettings.tt(0,0) : error CS0006: Compiling transformation: Metadata file 'Microsoft.VisualStudio.TextTemplating.Interfaces.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be found Registering the DLL