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.