随Visual Studio 2008的本机或与Visual Studio 2005 SDK中的T4模板,你几乎可以生成你想要的任何东西。
你可以有以下链接的详细信息:
我很确定所有这些链接对y而言都是一个好的开始我们的追求。
如果你想生成的Visual Studio之外T4模板,还有自定义MSBuild任务调用T4模板(link)
这里的MSBuild任务的“执行”的代码示例。 Click here for the source code:
public override bool Execute()
{
bool success = false;
//read in the template:
string template = File.ReadAllText(this.TemplatePath);
//replace tags with property and item group values:
ProjectHelper helper = new ProjectHelper(this);
template = helper.ResolveProjectItems(template);
//copy the template to a temp file:
this._tempFilePath = Path.GetTempFileName();
File.WriteAllText(this._tempFilePath, template);
//shell out to the exe:
ProcessHelper.Run(this, TextTransform.ToolPath, TextTransform.ExeName, string.Format(TextTransform.ArgumentFormat, this.OutputPath, this._tempFilePath));
success = true;
return success;
}
从我的理解来看,T4是设计时代的产物。我需要在运行时生成乳胶,类似于asp。如果T4可以在运行时调用,它看起来像是正确的工具,但我不确定它可以。 – Wyatt 2008-10-22 19:33:25