t4 templte位于目标项目目录之外

时间:2016-01-15 06:11:45

标签: c# t4

在一个解决方案中,t4模板文件在Frame.Model项目中

var path = solutionPath+@"\Frame.Service\Interface\"+config.FileName;
config.Output.Encoding = Encoding.UTF8;
config.RenderToFile(path);

这将为另一个项目生成代码,但错误, 消息:

*13 Output file D:\Code\Frame.Web\Frame.Service\Interface\IUser.generated.cs is located outside of directory of target project 

D:\Code\Frame.Web\Frame.Model\Frame.Model.csproj    
D:\Code\Frame.Web\Frame.Model\T4\EntityCodeScript.tt 1 1 Frame.Model*

当我改为:

var path = solutionPath+@"\Frame.Model\Interface\"+config.FileName;

那成功了,为什么不能在差异项目中生成文件? 怎么办? THK !!!

抱歉,我很擅长,我希望你能知道这是什么

1 个答案:

答案 0 :(得分:0)

您需要添加template.Output.Project。看看这篇文章。 http://www.olegsych.com/2009/03/t4-toolbox-generating-files-in-different-folders-and-projects/

相关问题