Project Options

The Project Options dialog allows you to configure behavior for the project. Some of the settings include a default template, single or multiple file output, default properties and project variables.

Configuring the Project Options

To view a Project Options you must click on the Project Options button. This button is located in the Manage Outputs toolbar as highlighted in green below.

Project Output

The project output option allow the selection between templates controlling output and all the templates output being merged into a single file. When single file output is selected, you can add a header and footer to the output file.

Default Properties

You can configure default properties to use within your CodeSmith Generator Project.  These properties are available to all of the templates assigned within your CodeSmith Generator Project.  These are especially useful to define properties that are fairly static in nature.

Variables

The CodeSmith Generator Project supports variables that can be used in the property sets. Variables are an easy way to have a common peace of data that is stored in only one place.

When saving a CodeSmith Project in the Manage Output dialog, the CodeSmith Generator Project will automatically create variables for all the unique connection strings in the project. This allows for easy updating of the connection string for complex projects.

Variable Usage

When using the Project Options dialog to edit variables, the variables will be placed in the property sets automatically when the project saves.  This is done by searching for all values that match the variables value and replacing it with the variable name.  The reverse is done when a project is loaded, all variable names are found and replaced with its value.

You can edit the CodeSmith Generator Project manually to place variables as well.  The variable for format is its name surrounded by $(), ie, $(ConnectionString1).

Sample Project File
<?xml version="1.0"?>
<codeSmith xmlns="http://www.codesmithtools.com/schema/csp.xsd">
    <singleOutput enabled="true" path="Data.cs" />
    <variables>
        <add key="ConnectionString1" value="Data Source=(local);Initial Catalog=PetShop;Integrated Security=True" />
        <add key="ProviderType" value="SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider" />
    </variables>
    <defaultProperties>
        <property name="DbmlFile">PetShop.dbml</property>
    </defaultProperties>
    <propertySets>
        <propertySet name="Dbml" template="CSharp\Dbml.cst">
           <property name="IncludeViews">False</property>
           <property name="IncludeFunctions">False</property>
           <property name="EntityBase">LinqEntityBase</property>
           <property name="DisableRenaming">False</property>
           <property name="SourceDatabase">
                <connectionString>$(ConnectionString1)</connectionString>
                <providerType>$(ProviderType)</providerType>
            </property>
            <property name="EntityNamespace">PetShop.Data</property>
            <property name="ContextNamespace">PetShop.Data</property>
        </propertySet>
        <propertySet name="Entities" template="CSharp\Entities.cst">
            <property name="IncludeDataContract">True</property>
            <property name="OutputDirectory">PetShop\PetShop.Data</property>
        </propertySet>
    </propertySets>
</codeSmith>