The past week I was busy creating an automated template based system for generating Developer Express‘ XPO source code. Heart of the system is based on CodeSmith and my custom templates (perhaps more details about the system in a later post).
Once I’ve finished all my templates for generating fine XPO code (everything is really powerful and flexible, trust me :-)) I had to find a way to automate the (re)build since there is not only one template.
One of the option was to use CodeSmithGenerator that spits out code based on input parameters in XML file that is part of your project (the same system is used by MSDataSetGenerator). The only weakness of this approach is that it requires several clicks if you have more than one template.
So I went with out of IDE build process because I like to do everything within the single action. Again, I faced three choices:
- Use good old command line bat file.
This would do, but feedback is poor and it won’t do handle Visual Source Safe. - Use MSBuild tool that comes with .net 2.
CodeSmith 3.2 comes with custom MSBuild taks that takes care of running the template generator. However, MSBuild is rather limited out of the box – no UI and no VSS control. - FinalBuilder4. This is great automated build tool and perfect for me in this case. The only drawback is that it doesn’t know how to run CodeSmith generator. On the other hand it does everything else.
I went with option 3. But I did have to build an action for running CodeSmith generator. Fortunately for me, build custom actions for FB4 is really simple (I did it before for XSD tool). After a hour or so of coding in VBScript (the easiest way to create a simple FinalBuilder4 action) CodeSmith action was created. The settings screen looks like this:
There are is no support for merging at this point simply because I didn’t need it. I might add it in next version.
The result is that I simply invoke FinalBuilder4 via a shortcut and it does everything for me (check out files before, runs CodeSmith generator and check in files after).
You can find CodeSmith action here.