Versions Compared

Key

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

CodeSmith uses the GetFileName method to provide a default output filename for the template when it's called from the CodeSmith Console Application. This is also used in CodeSmith Studio as the default file name if you save the output of a template, and anywhere else that CodeSmith needs to assign a filename to the output of your template. You can override this method in your code when you want to build the default file name based on property input or other factors.

For example, if your C# language template contains a property named ClassName, you might include this code to set the default output file name:

Code Block
xml
xml

<script runat="template">
public override string GetFileName() {
    return ClassName + ".cs";
}
</script>