Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To manage a CodeSmith Project, you can use the Right-Click context menu of a CodeSmith Project file from the Solution Explorer window.  Image Modified

(Depicted on the right)

The menu options include:

  1. Generate Outputs - Will kick off the generation process to produce outputs configured in your CodeSmith Project.
  2. Manage Outputs - Gives the ability to manage your CodeSmith Project.
  3. Add Outputs
  4. Output Options - (Depicted below) Only available in Visual Studio, and allows you to control the output options after generation.
    IMAGE GOES HERE
    1. Add Outputs To Project - Will take any outputs from your CodeSmith Project and include them in your Visual Studio project.
    2. Hide Outputs - Will take any outputs of your CodeSmith Project and make them child nodes, dependant on your CodeSmith Project file (shown below).  Hidden nodes can be collapsed, and since much of the time generated code shoudln't be touched, it's a great way to hide the temptation of other developers attempting to modify the generated code.
    3. Generate On Build - A menu driven way to have your templates use Active Generation.  You can also specify the BuildAction value in the property sheet of your CodeSmith Project. (more below)
      Image Modified
Active Generation

You can use ActiveGeneration quite easily in your Visual Studio projects now, simply by specifying the BuildAction of your CodeSmith Project. Image Modified

Setting the BuildAction = "Generate" in the properties of you CodeSmith Project file in the Solution Explorer will cause your entire generation process to occur prior to your project building.  This means that any Outputs that you have in your CodeSmith Project will be generated  and if you want, included in the Visual Studio project.

...

As you can see depicted in the image below, the business object was generated, and then the build process began.  This is a very powerful feature since it allows you to have strong Code Generation integration inside all of your projects in Visual Studio without having to switch to CodeSmith Studio or Explorer.

Image Modified

Adding Files to Visual Studio Using DependentUpon Hierarchy

CodeSmith 5.0 added a new overload to the templates RenderToFile that will take a parent (DependentUpon) file. This will add metadata to the output file that Visual Studio will use when adding the file to create the hierarchy.

Image Modified

To get your template to support this, you'll need to update the template to use the RenderToFile overload that takes a parent file.  Next, add the CodeSmith Project to the Visual Studio project and Generate Outputs. CodeSmith will automaticly add the outputs to your Visual Studio project creating the hierarchy.

...