Xamarin Studio / MonoDevelop T4 pre-build

拥有回忆 提交于 2020-01-04 02:44:47

问题


Is there a way, with Xamarin Studio, to have a pre build command that runs a T4 template? This would help generating a C# file on the fly.


回答1:


Ok here is the solution if somebody is interested:

Just create a mono-t4 file in your solution folder:

#!/bin/bash
mono /Applications/Xamarin\ Studio.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.TextTemplating/TextTransform.exe -o $1 $2

Don't forget to make it executable with

chmod +x mono-t4

Then in your project options, in "Custom commands" add a "Before-Build" command. Command is:

${SolutionDir}/mono-t4 YourOutputCSharpFile.cs ${ProjectDir}/YourInputT4.tt

Then everytime you will compile you will get your csharp file up to date.



来源:https://stackoverflow.com/questions/18575019/xamarin-studio-monodevelop-t4-pre-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!