Xamarin Studio/MonoDevelop T4 预构建 [英] Xamarin Studio / MonoDevelop T4 pre-build
本文介绍了Xamarin Studio/MonoDevelop T4 预构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用 Xamarin Studio 来拥有运行 T4 模板的预构建命令?这将有助于动态生成 C# 文件.
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.
推荐答案
如果有人感兴趣,这里是解决方案:
Ok here is the solution if somebody is interested:
只需在您的解决方案文件夹中创建一个 mono-t4 文件:
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
不要忘记使用
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
然后每次编译时都会更新 csharp 文件.
Then everytime you will compile you will get your csharp file up to date.
这篇关于Xamarin Studio/MonoDevelop T4 预构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文