Incorporating Generator into Your Build Process

Using Template Explorer or the Visual Studio integration interactively to generate code can significantly boost your productivity, but that's only part of what CodeSmith Generator can do for you. In many cases, you'll see even more benefit by incorporating CodeSmith Generator directly into your build process. To facilitate this, CodeSmith Generator includes a console version that you can call from a CodeSmith Project, a build tool such as NAnt. or a Visual Studio pre-compile task in MSBuild. This helps you ensure that any generated files in your application are always up-to-date.

For example, suppose you are using CodeSmith Generator to automatically create a data access layer and business objects in C# based on selected tables in your database. What happens if you change the schema of those database tables? If you're using CodeSmith Generator manually, you must remember to regenerate the DAL and business objects. But if you've hooked up the CodeSmith Generator Console Application to your build process, the changes in the database schema will automatically be reflected in your final .NET application the next time that you compile the application, without any further effort on your part.

In this section of the help file, you can learn how to: