Incorporating Generator into Your Build Process
Generating code interactively with Template Explorer or Visual Studio can save you a lot of time. You often get even more benefit by making CodeSmith Generator part of your build process, so that the generated files in your application are always up to date.
For example, suppose you use Generator to create a data access layer and business objects in C# from tables in your database. What happens when you change the schema of those tables? If you generate code by hand, you have to remember to regenerate the data access layer and business objects. If Generator is part of your build, the schema changes are picked up the next time you build your application, with no extra effort.
Ways to generate during a build
Each of these runs a Generator project, which stores the templates and property values to generate:
| Method | Use it when |
|---|---|
| Generate build action | You want a Generator project in a Visual Studio project to regenerate on every build. |
| MSBuild task | You need to customize when or how generation runs in an MSBuild build. |
| Console application | You run a script, batch file or another build tool. |
Next steps
- Console application usage: command-line switches and options.
- Setting property values: supply template metadata on the command line.