t4

T4 Templates and Visual Studio Item Templates

一曲冷凌霜 提交于 2019-12-10 10:16:49
问题 Is it possible to create a Visual Studio item template that generates from a T4 template? My google-fu does not seem powerful enough to yield an answer! 回答1: Yes, you need to use GAX for that. It has a (rather limited implementation of) custom T4 host that allows you to use T4 as a template language. 回答2: Yes you can, actually ASP.NET MVC uses this approach when creating View item from Controller item All the Best Muse VSExtensions 来源: https://stackoverflow.com/questions/805979/t4-templates

t4 generate file with no DependentUpon attribute in csproj file

筅森魡賤 提交于 2019-12-10 08:45:09
问题 We are using t4 templates for managing configurations in our project. And web.config file is generated via web.tt file. After generation in csproj file I have following: <Content Include="Web.config"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>Web.tt</DependentUpon> </Content> Is it possible to configure t4 template somehow to generate independent web.config file, not under web.tt? 回答1: Yes you can. First define a save routine in a T4 include file. SaveOutput.tt : <#

Running TextTransform.exe (T4) on a build server

冷暖自知 提交于 2019-12-10 03:36:44
问题 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,

Is there an EF6 DbContext Generator for C# which uses Fluent API?

落爺英雄遲暮 提交于 2019-12-09 07:12:53
问题 I know that the EF6 VS Tools for Visual Studio 2012 come with a T4 template to generate DbContext classes which work with EF6. But I want to have a generator which uses fluent API. The older version I used with EF4 and EF5 don't work with EF6 and the author no longer works on them to make them EF6 compatible. Is anyone else working on a generator which uses Fluent API which works with EF6? 回答1: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d If you have a

Auto-generate a strongly-typed AppSettings class

血红的双手。 提交于 2019-12-09 06:25:07
问题 Here's the question first: Is this possible? I'm taking my inspiration from Joe Wrobel's work (a redux of the forgotten Codeplex project). Here, you do your work on creating your profile for the provider, and it does the legwork of creating the strong typing for it, effectively creating a facade for the Profile class. And now the back story! I really don't like magic strings. They're pretty bad and can cause some serious issues when it comes to updating your application. Having worked in

T4 template will not transform with build

[亡魂溺海] 提交于 2019-12-09 02:38:11
问题 I'm using VisualStudio Ultimate 2012 (Update 1) on Windows 7. I can get my T4 template to generate a file by: right click [tt file] | run Custom tool . That works great! (yay for me). It also works if I run the menu command: Build | Transform All T4 Templates . But I want automation! I run into a problem when I try to get the generated code file to be produced with every build -- which is my goal. I looked at this: T4 transformation and build order in Visual Studio this isn't what I want. It

Can I execute code from another file in a T4 .tt template for code generation?

自古美人都是妖i 提交于 2019-12-08 15:56:08
问题 I'm using several T4 templates to generate several T4 files, and most of them share a lot of the same code, so naturally I would like to make a function out of it and put it in a different file that all of the T4 files could access. However I can't seem to find a way, or google for a way to actually use code stored in another file. Is this possible? and if so, is there a simple example of how to do so? 回答1: From your question, it sounds like you're just using T4 in a normal template file in

MSBuild locking dll used on T4 template generated on build

不羁岁月 提交于 2019-12-08 15:51:39
问题 I'm having a lot of trouble trying to identify why MSBuild is blocking access to a dll used inside a new T4 template I just created. The problem is kind of hard to explain (and even ask, as is evident by the title). I created a T4 template to generate a c# class that is a wrapper to N other classes we have. This was the solution I came up with to expose multiple WCF Services over the same endpoint. The template code itself uses an assembly (Mobiltec.Framework.dll) that contains various

Clearing Custom Tool file property in Visual Studio 2010

白昼怎懂夜的黑 提交于 2019-12-08 13:50:18
问题 Is there any way to prevent prevent a custom tool from running or remove the custom tool for a file type per project in Visual Studio? In my example I would like to add a file to my project with an extension (.tt) that Visual Studio assoicates with the TextTemplatingFileGenerator. I would like to not have to go into the file properties and clear the Custom Tool property as well as clean up any work done by the single file generator that runs when adding the file to my project. 回答1: In the

Write T4 generated code to separate output files

☆樱花仙子☆ 提交于 2019-12-08 10:08:30
问题 I am creating a .tt file that transforms text into model classes, to practice. A .cs file is generated that with all models , but I would like each model to be saved in its own .cs file in a different folder. What would be the best approach to achieve this? 回答1: Here is simple example how you can output multiple files from single T4 template. Using SaveOutput -method output files ( Content1.txt,Content2.txt ..) are created to same folder than .tt-file, with SaveOutputToSubFolder output files