Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top