Using CodeSmith Generator Projects

CodeSmith Generator Projects manage groups of CodeSmith Generator templates and their outputs all in a single CodeSmith Generator Project file (.csp). CodeSmith Generator Projects are files that enable you to run an entire generation process at anytime in a simplistic manner from many different environments.

About

A CodeSmith Generator Project file uses a .csp file windows extension, and stores XML metadata about your CodeSmith Generator Project.

Learn more by reading Anatomy of a Project File.

A CodeSmith Generator Project file can be generated or configured by right clicking on on a CodeSmith Generator Project File (.csp). 

Generation Capabilities

CodeSmith Generator Project files enable the management and execution of a generation process in many environments.

Windows Explorer and Template Explorer 

Managing a CodeSmith Generator Project right from Windows Explorer is simple and doesn't require you to use CodeSmith Generator to manage a project. Options are available through the right-click context menu in your CodeSmith Generator Project file (.csp). 
The menu options include:

  1. Manage Outputs - Gives the ability to manage your CodeSmith Generator Project.
  2. Generate Outputs - Will kick off the generation process to produce outputs configured in your CodeSmith Generator Project.
  3. Add Outputs

Command-Line

You can Generate Outputs of a CodeSmith Generator Project in the command line by using the using the CodeSmith Generator Console Application.  You would simply call:

cs MyCodeSmithProject.csp

Visual Studio

The tight integration with Visual Studio allows you to fully manage any CodeSmith Generator Project right from Visual Studio!  This means you can maintain a high Code Generation presence right within Visual Studio and not have to switch applications to run code generation. 

  1. Manage Outputs - Gives the ability to manage your CodeSmith Generator Project.
  2. Generate Outputs - Will kick off the generation process to produce outputs configured in your CodeSmith Generator Project.
  3. Add Outputs
  4. Output Options - Only available in Visual Studio, and allows you to control the output options after generation.

MSBuild

You can create your own custom pre-generation build logic by utilizing the CodeSmith Generator Task within MSBuild. MSBuild tasks help manage the build process within your Visual Studio projects. 

There might be times when you need to customize some aspect of the generation process during it's consuming build process. During these time you might have to call CodeSmith Generator from MSBuild using the CodeSmith Generator task that's shipped for you.