Using CodeSmith Generator Projects

A CodeSmith Generator project manages a group of templates and their outputs in a single project file with a .csp extension. The project file stores, as XML, which templates to run, the property values for each one and where their output goes. You can then run the whole generation process at any time, from many different environments.

To learn what's inside a project file, see Anatomy of a project file.

Project commands

Right-click a project file to work with it. These commands are available everywhere you can use a project file:

Command What it does
Manage Outputs Opens the Manage Outputs dialog, where you add, edit and remove outputs and set project options.
Generate Outputs Runs the generation process and produces all of the outputs in the project.
Add Output Adds a new output to the project. See Adding and editing outputs.

Where you can use projects

Visual Studio

Add project files to your Visual Studio projects and manage and generate them from Solution Explorer, so you don't have to switch applications to generate code. Visual Studio also adds Output Options, which control what happens to the outputs after generation, and can regenerate the outputs every time you build.

See Using a Generator project inside Visual Studio.

File Explorer and Template Explorer

Right-click a project file in File Explorer or Template Explorer to manage and generate its outputs, without opening Generator.

See Using a Generator project from Windows Explorer.

Command line

Generate a project's outputs from the command line, a batch file or any application that can start a process, with the console application:

cs MyCodeSmithProject.csp

See Using a Generator project from the command line.

MSBuild

Run Generator projects as part of your build with the CodeSmith Generator MSBuild task, for example to customize when and how code is generated.

See Using a Generator project from MSBuild.

In this section