问题
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