Executing Templates
To execute a template from Template Explorer, double-click the template, or right-click the template and select Execute. You can also drag the template from Template Explorer and drop it on any application that supports drag-and-drop to generate code at the location where you dropped the template. Any of these actions will open the template's property sheet.
The template's property sheet shows you all of the properties that you can set for this template. Properties can be required or optional. You need to supply values for all required properties before CodeSmith Generator can generate the code for you. Depending on how a property is defined in the template, you may be able to type in an arbitrary value, select a value from a predefined list, or choose a value by navigating to a dialog box from a builder button within the property sheet. Properties may also have default values. As you select each property, a description will appear at the bottom of the property sheet to tell you more about that property.
In the screenshot above, the user has selected the SourceDatabase property, and the description indicates that this property specifies the Database that the documentation will be created for.Â
With the SourceDatabase property selected, the right side of the property sheet shows the builder button (with three dots) as shown highlighted in green. Clicking this button will open a separate dialog box (in this case, a dialog box supplied by CodeSmith Generator's own SchemaExplorer metadata extension) to help you pick a value for this property.
When you have finished setting properties for the template, you're ready to generate code. To do this, click the Generate button at the bottom of the template's property sheet. CodeSmith Generator will take the property values that you entered and combine them with the template to create the code, and display it in an Output Window or output it to a specific directory. In this case the code will be generated to the folder specified in the OutputDirectory property.
Click here to learn about the property sheet toolbar.
Advanced: Using a CodeSmith Generator Project to Execute CodeSmith Templates from Anywhere