<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="http://www.codeplex.com/rss.xsl"?><rss version="2.0"><channel><title>Gauntlet</title><link>http://www.codeplex.com/Gauntlet/Project/ProjectRss.aspx</link><description>A .NET code generation tool that integrates seamlessly with MSBuild.</description><item><title>UPDATED RELEASE: Gauntlet V1.0.0.0 (May 18, 2008)</title><link>http://www.codeplex.com/Gauntlet/Release/ProjectReleases.aspx?ReleaseId=13530</link><description>This is version 1.0.0.0 of Gauntlet.</description><author></author><pubDate>Sun, 18 May 2008 15:28:04 GMT</pubDate><guid isPermaLink="false">UPDATED RELEASE: Gauntlet V1.0.0.0 (May 18, 2008) 20080518032804P</guid></item><item><title>Source code checked in</title><link>http://www.codeplex.com/Gauntlet/SourceControl/ListDownloadableCommits.aspx</link><description>- initial commit</description><author>kentcb</author><pubDate>Sun, 18 May 2008 15:22:45 GMT</pubDate><guid isPermaLink="false">Source code checked in 20080518032245P</guid></item><item><title>UPDATED WIKI: User Documentation</title><link>http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=User Documentation&amp;version=5</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
User Documentation
&lt;/h1&gt;&lt;h2&gt;
Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Introduction"&gt;Introduction&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#WhyAnotherCodeGenerationTool"&gt;Why Another Code Generation Tool&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#HowMightIUseGauntlet"&gt;How Might I Use Gauntlet?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;&lt;a href="#Design"&gt;Design&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Assemblies"&gt;Assemblies&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#GenerationProcess"&gt;Generation Process&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;&lt;a href="#UsingGauntlet"&gt;Using Gauntlet&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#IntegratingWithMSBuild"&gt;Integrating with MSBuild&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#OutOfTheBoxFunctionality"&gt;Out-of-the-box Functionality&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;&lt;a name="Introduction"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Introduction
&lt;/h1&gt;Gauntlet is a .NET code generation tool with emphases on simplicity, extensibility, and seamless integration with the .NET build system. It is designed to slot right into your build process, alleviating you of the need to run an external tool for code generation.&lt;br /&gt;&lt;a name="WhyAnotherCodeGenerationTool"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Why Another Code Generation Tool?
&lt;/h2&gt;There is a plethora of code generation tools available for .NET, some commercial and some – like Gauntlet – open source. Why is there a need for another?&lt;br /&gt; &lt;br /&gt;Gauntlet differs from other code generators by integrating seamlessly with .NET’s build platform, MSBuild. What this means is that when you change an input or template file, you simply build your project to have the corresponding output generated. This works the same whether you’re building from the command line or from within Visual Studio. There is no need to start up an external tool, or even to know that Gauntlet is being used to generate the output.&lt;br /&gt; &lt;br /&gt;Gauntlet also provides extensibility points for the entire generation process. If you need to support a custom input format, you can. If you need to integrate with a proprietary template engine, you can.&lt;br /&gt;&lt;a name="HowMightIUseGauntlet"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
How Might I Use Gauntlet?
&lt;/h2&gt;The possibilities really are endless, but here are some examples to illustrate:&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Ever wanted more control over the web service clients that Visual Studio generates for web references? Using Gauntlet you could write your own template and take full control of the code, using the WSDL as the input to the generation process.&lt;/li&gt;&lt;li&gt;Most domain layers are very repetitive: they’re essentially a bunch of data classes with some business logic sprinkled throughout. Using Gauntlet, you could define a template for your domain objects and save a heap of time and maintenance cost. Your input file could be a simple XML structure defining the properties of your domain object. The template could contain the logic to generate fields, properties, property change notifications (for data binding), custom serialization logic (to increase serialization speeds) etcetera.&lt;/li&gt;&lt;li&gt;Ever had to work with a framework that imposes ridiculous restrictions that stop you from using inheritance to factor out common functionality? &lt;b&gt;*cough*&lt;/b&gt; MAF &lt;b&gt;*cough*&lt;/b&gt; Well, you could succumb to the evil will of the framework and write the same code a hundred times, or you could write a template and generate that code instead.&lt;/li&gt;
&lt;/ul&gt;&lt;a name="Design"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Design
&lt;/h1&gt;&lt;a name="Assemblies"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Assemblies
&lt;/h2&gt;Gauntlet’s key components are divided into two assemblies: &lt;i&gt;Kent.Boogaart.Gauntlet&lt;/i&gt; and &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild&lt;/i&gt;. The former defines the core Gauntlet interfaces and provides some generic implementations of these interfaces. The latter provides support for incorporating Gauntlet into MSBuild scripts.&lt;br /&gt; &lt;br /&gt;If you’re writing custom components to hook into the Gauntlet generation process, you’ll need to reference &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;. If you’re simply using Gauntlet in your build process, both assemblies are used and the instructions for setting up can be found &lt;a href="#IntegratingWithMSBuild"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;a name="GenerationProcess"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generation Process
&lt;/h2&gt;Gauntlet’s code generation process is depicted below:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34806" alt="CodeGenerationProcess.png" /&gt;&lt;br /&gt; &lt;br /&gt;The input and template files are fed into a regeneration policy. The regeneration policy decides whether the generation should continue or be skipped altogether. If continued, an input translator is used to translate the input file into something that can be consumed by the output generator. The output generator is responsible for converting the translated input into the final output file. A context is passed through the whole generation process. This context can be used by the various components of the pipeline to make decisions or store state.&lt;br /&gt; &lt;br /&gt;All pipeline components are extensible. You can provide your own regeneration policy, input translator, output generator, or even a custom context implementation. Gauntlet comes with various useful implementations of all of these components and it will often be unnecessary for you to write your own, but the extensibility points are there if required.&lt;br /&gt; &lt;br /&gt;Missing from the above diagram is a depiction of logging. The context passed through the generation process includes a property of type &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.ILog&lt;/span&gt;. This interface defines methods for logging messages and exceptions, and can be used by components in the generation pipeline. The particular implementation of ILog present will determine how log entries are manifested. When using Gauntlet from within your MSBuild script, log statements will flow through to the build output. Therefore, if an error is logged, it will appear as an error when building from within Visual Studio.&lt;br /&gt;&lt;a name="UsingGauntlet"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Using Gauntlet
&lt;/h1&gt;&lt;a name="IntegratingWithMSBuild"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Integrating With MSBuild
&lt;/h2&gt;In order to integrate Gauntlet into your build process, you need to follow a number of simple steps. As of version 1.0 of Gauntlet, there is no Visual Studio integration. Therefore, these steps must be performed manually. Note that you can still build from Visual Studio (since Visual Studio uses MSBuild behind the scenes). However, there is no Visual Studio add-in to perform the steps below automatically.&lt;br /&gt; &lt;br /&gt;There is a sample solution called &lt;i&gt;IntegratingGauntletWithMSBuild.sln&lt;/i&gt; that shows the results of all these steps being applied. Inside this solution there is a single project called &lt;i&gt;ConsoleApplication&lt;/i&gt;, which uses Gauntlet to generate an enumeration called &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt;. When the application is executed, it outputs the members of this enumeration to the console.&lt;br /&gt;&lt;h3&gt;
Ensure Gauntlet Files are Available to Build Process
&lt;/h3&gt;First of all, make sure that the Gauntlet files are available to your build process. An easy way to do this is to place them under a Lib (or similar) directory in your project’s folder structure. I normally have a Lib folder to store referenced assemblies anyway, so I just create a Lib\Gauntlet folder to store the Gauntlet assemblies. You can see this in the sample:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34807" alt="FolderStructure.png" /&gt;&lt;br /&gt; &lt;br /&gt;There are a number of files that need to be placed in this folder: &lt;i&gt;Kent.Boogaart.HelperTrinity.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild.dll&lt;/i&gt;, &lt;i&gt;Gauntlet.targets&lt;/i&gt;, and &lt;i&gt;NVelocity.dll&lt;/i&gt;:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34808" alt="GauntletFiles.png" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Import Gauntlet into Relevant Project(s)
&lt;/h3&gt;The next step is to determine which projects in your solution need to use Gauntlet, and to import Gauntlet targets into their build script. This requires the addition of an &lt;span class="codeInline"&gt;&amp;lt;Import/&amp;gt;&lt;/span&gt; element in the MSBuild file. For example, the ConsoleApplication.csproj file includes this:&lt;br /&gt;&lt;pre&gt;
&amp;lt;Import Project=&amp;quot;..\Lib\Gauntlet\Gauntlet.targets&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Define Templates
&lt;/h3&gt;Next, add a template to your project. If you’re using the NVelocity output generator (more on this later) then the template just needs to be a text file that contains an NVelocity template. The sample project contains a file called &lt;i&gt;GeneratedEnum.template&lt;/i&gt;, which is responsible for converting the input into an enumeration. The contents are as follows:&lt;br /&gt;&lt;pre&gt;
namespace ConsoleApplication
{
	public enum GeneratedEnum
	{
		#foreach ($member in $GeneratedEnum.Members.Member)
			$member.Name,
		#end
	}
}
&lt;/pre&gt;&lt;h3&gt;
Define Input File
&lt;/h3&gt;Now that we have a template, we need to add a file to serve as input to the code generation process. In this case, we’re using Gauntlet’s built-in XML input translator, so the input file – which I called &lt;i&gt;GeneratedEnum.input&lt;/i&gt; – is in an XML format. The contents of this file are:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;GeneratedEnum&amp;gt;
	&amp;lt;Members&amp;gt;
		&amp;lt;Member Name=&amp;quot;One&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Two&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Three&amp;quot;/&amp;gt;
	&amp;lt;/Members&amp;gt;
&amp;lt;/GeneratedEnum&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Generate the Output File
&lt;/h3&gt;Now that we have both template and input files, we need to tie the two together to produce the output file. To do this, we need to edit the project file manually. Open the project file and locate the input file’s entry. Change its type from &lt;span class="codeInline"&gt;None&lt;/span&gt; to &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot; /&amp;gt;
&lt;/pre&gt;Next, include the details of the template file, output file, input translator, and output generator inside the item definition:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot;&amp;gt;
	&amp;lt;TemplateFile&amp;gt;GeneratedEnum.template&amp;lt;/TemplateFile&amp;gt;
	&amp;lt;OutputFile&amp;gt;GeneratedEnum.g.cs&amp;lt;/OutputFile&amp;gt;
	&amp;lt;InputTranslator&amp;gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator, Kent.Boogaart.Gauntlet&amp;lt;/InputTranslator&amp;gt;
	&amp;lt;OutputGenerator&amp;gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator, Kent.Boogaart.Gauntlet&amp;lt;/OutputGenerator&amp;gt;
&amp;lt;/GeneratedItem&amp;gt;
&lt;/pre&gt;Without this information, the build process will fail with an appropriate error. That’s because Gauntlet attempts to process any files that are &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;s.&lt;br /&gt;&lt;h3&gt;
Include the Output File
&lt;/h3&gt;Once the above step is complete, build your project. All being well, you should see the output file in your project’s folder. Note that the build may fail, but the output file should still be generated. That’s because the output file has not yet been included into your project, and the &lt;span class="codeInline"&gt;Program&lt;/span&gt; class is assuming the existence of a &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt; type, which is defined by the output file.&lt;br /&gt; &lt;br /&gt;An easy way to include the output file in the solution is from Visual Studio’s solution explorer. First, click show all files for the project (the highlighted icon below):&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34810" alt="ShowAllFiles.png" /&gt;&lt;br /&gt; &lt;br /&gt;You will then see the &lt;i&gt;GeneratedEnum.g.cs&lt;/i&gt; file:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34811" alt="ShowAllFiles2.png" /&gt;&lt;br /&gt; &lt;br /&gt;Right-click the file and choose &lt;i&gt;Include In Project&lt;/i&gt;:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34809" alt="IncludeInProject.png" /&gt;&lt;br /&gt; &lt;br /&gt;Now the output file is included in the project. If you execute the project, you should see all the members of the enumeration listed. Try playing with the input file and re-executing the application.&lt;br /&gt;&lt;a name="OutOfTheBoxFunctionality"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Out-of-the-box Functionality
&lt;/h2&gt;This section discusses the functionality that Gauntlet provides out-of-the-box.&lt;br /&gt;&lt;h3&gt;
XML Input Translator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator&lt;/span&gt; class is an input translator that takes any XML document and places in the current context for consumption by the output generator. It uses the root of the XML document as a key under which the XML is stored. From there, it permits a simple property syntax to navigate the XML document.&lt;br /&gt; &lt;br /&gt;For example, suppose you have the following XML input:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;BusinessObject ClassName=&amp;quot;Customer&amp;quot; Namespace=&amp;quot;BusinessObjects&amp;quot;&amp;gt;
	&amp;lt;Properties&amp;gt;
		&amp;lt;Property Name=&amp;quot;Name&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;DOB&amp;quot; Type=&amp;quot;DateTime&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;Address&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
	&amp;lt;/Properties&amp;gt;
&amp;lt;/BusinessObject&amp;gt;
&lt;/pre&gt;Using the NVelocity output generator (see below), the class name can be accessed via the syntax &lt;span class="codeInline"&gt;$BusinessObject.ClassName&lt;/span&gt; and the collection of properties can be obtained via the syntax &lt;span class="codeInline"&gt;$BusinessObject.Properties.Property&lt;/span&gt;.&lt;br /&gt;&lt;h3&gt;
NVelocity Output Generator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator&lt;/span&gt; class is an output generator that assumes the template file is an NVelocity template. It takes all items in the Gauntlet context’s state bag and passes them into the NVelocity context for the template to consume.&lt;br /&gt;&lt;h3&gt;
Timestamp Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.TimestampRegenerationPolicy&lt;/span&gt; class is used by default, and uses the timestamps of the files to determine whether code generation is required.&lt;br /&gt;&lt;h3&gt;
Forced Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.ForcedRegenerationPolicy&lt;/span&gt; class is a regeneration policy that always generates code, regardless of whether the generation is actually necessary. It should be used with caution.&lt;br /&gt;&lt;h3&gt;
Default Context
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.Context&lt;/span&gt; is a base context implementation that is used unless otherwise specified. It includes properties to get the various files included in the generation, a timestamp for when the generation process began, a log, and a state bag.&lt;br /&gt;
&lt;/div&gt;</description><author>kentcb</author><pubDate>Sun, 18 May 2008 15:07:44 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: User Documentation 20080518030744P</guid></item><item><title>UPDATED WIKI: User Documentation</title><link>http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=User Documentation&amp;version=4</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
Introduction
&lt;/h1&gt;Gauntlet is a .NET code generation tool with emphases on simplicity, extensibility, and seamless integration with the .NET build system. It is designed to slot right into your build process, alleviating you of the need to run an external tool for code generation.&lt;br /&gt;&lt;h2&gt;
Why Another Code Generation Tool?
&lt;/h2&gt;There is a plethora of code generation tools available for .NET, some commercial and some – like Gauntlet – open source. Why is there a need for another?&lt;br /&gt; &lt;br /&gt;Gauntlet differs from other code generators by integrating seamlessly with .NET’s build platform, MSBuild. What this means is that when you change an input or template file, you simply build your project to have the corresponding output generated. This works the same whether you’re building from the command line or from within Visual Studio. There is no need to start up an external tool, or even to know that Gauntlet is being used to generate the output.&lt;br /&gt; &lt;br /&gt;Gauntlet also provides extensibility points for the entire generation process. If you need to support a custom input format, you can. If you need to integrate with a proprietary template engine, you can.&lt;br /&gt;&lt;h2&gt;
How Might I Use Gauntlet?
&lt;/h2&gt;The possibilities really are endless, but here are some examples to illustrate:&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Ever wanted more control over the web service clients that Visual Studio generates for web references? Using Gauntlet you could write your own template and take full control of the code, using the WSDL as the input to the generation process.&lt;/li&gt;&lt;li&gt;Most domain layers are very repetitive: they’re essentially a bunch of data classes with some business logic sprinkled throughout. Using Gauntlet, you could define a template for your domain objects and save a heap of time and maintenance cost. Your input file could be a simple XML structure defining the properties of your domain object. The template could contain the logic to generate fields, properties, property change notifications (for data binding), custom serialization logic (to increase serialization speeds) etcetera.&lt;/li&gt;&lt;li&gt;Ever had to work with a framework that imposes ridiculous restrictions that stop you from using inheritance to factor out common functionality? &lt;b&gt;cough&lt;/b&gt; MAF &lt;b&gt;cough&lt;/b&gt; Well, you could succumb to the evil will of the framework and write the same code a hundred times, or you could write a template and generate that code instead.&lt;/li&gt;
&lt;/ul&gt;&lt;h1&gt;
Design
&lt;/h1&gt;&lt;h2&gt;
Assemblies
&lt;/h2&gt;Gauntlet’s key components are divided into two assemblies: &lt;i&gt;Kent.Boogaart.Gauntlet&lt;/i&gt; and &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild&lt;/i&gt;. The former defines the core Gauntlet interfaces and provides some generic implementations of these interfaces. The latter provides support for incorporating Gauntlet into MSBuild scripts.&lt;br /&gt; &lt;br /&gt;If you’re writing custom components to hook into the Gauntlet generation process, you’ll need to reference &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;. If you’re simply using Gauntlet in your build process, both assemblies are used and the instructions for setting up can be found &lt;b&gt;here&lt;/b&gt;.&lt;br /&gt;&lt;h2&gt;
Generation Process
&lt;/h2&gt;Gauntlet’s code generation process is depicted below:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34806" alt="CodeGenerationProcess.png" /&gt;&lt;br /&gt;The input and template files are fed into a regeneration policy. The regeneration policy decides whether the generation should continue or be skipped altogether. If continued, an input translator is used to translate the input file into something that can be consumed by the output generator. The output generator is responsible for converting the translated input into the final output file. A context is passed through the whole generation process. This context can be used by the various components of the pipeline to make decisions or store state.&lt;br /&gt; &lt;br /&gt;All pipeline components are extensible. You can provide your own regeneration policy, input translator, output generator, or even a custom context implementation. Gauntlet comes with various useful implementations of all of these components and it will often be unnecessary for you to write your own, but the extensibility points are there if required.&lt;br /&gt; &lt;br /&gt;Missing from the above diagram is a depiction of logging. The context passed through the generation process includes a property of type &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.ILog&lt;/span&gt;. This interface defines methods for logging messages and exceptions, and can be used by components in the generation pipeline. The particular implementation of ILog present will determine how log entries are manifested. When using Gauntlet from within your MSBuild script, log statements will flow through to the build output. Therefore, if an error is logged, it will appear as an error when building from within Visual Studio.&lt;br /&gt;&lt;h1&gt;
Using Gauntlet
&lt;/h1&gt;&lt;h2&gt;
Integrating With MSBuild
&lt;/h2&gt;In order to integrate Gauntlet into your build process, you need to follow a number of simple steps. As of version 1.0 of Gauntlet, there is no Visual Studio integration. Therefore, these steps must be performed manually. Note that you can still build from Visual Studio (since Visual Studio uses MSBuild behind the scenes). However, there is no Visual Studio add-in to perform the steps below automatically.&lt;br /&gt; &lt;br /&gt;There is a sample solution called &lt;i&gt;IntegratingGauntletWithMSBuild.sln&lt;/i&gt; that shows the results of all these steps being applied. Inside this solution there is a single project called &lt;i&gt;ConsoleApplication&lt;/i&gt;, which uses Gauntlet to generate an enumeration called &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt;. When the application is executed, it outputs the members of this enumeration to the console.&lt;br /&gt;&lt;h3&gt;
Ensure Gauntlet Files are Available to Build Process
&lt;/h3&gt;First of all, make sure that the Gauntlet files are available to your build process. An easy way to do this is to place them under a Lib (or similar) directory in your project’s folder structure. I normally have a Lib folder to store referenced assemblies anyway, so I just create a Lib\Gauntlet folder to store the Gauntlet assemblies. You can see this in the sample:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34807" alt="FolderStructure.png" /&gt;&lt;br /&gt;There are a number of files that need to be placed in this folder: &lt;i&gt;Kent.Boogaart.HelperTrinity.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild.dll&lt;/i&gt;, &lt;i&gt;Gauntlet.targets&lt;/i&gt;, and &lt;i&gt;NVelocity.dll&lt;/i&gt;:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34808" alt="GauntletFiles.png" /&gt;&lt;br /&gt;&lt;h3&gt;
Import Gauntlet into Relevant Project(s)
&lt;/h3&gt;The next step is to determine which projects in your solution need to use Gauntlet, and to import Gauntlet targets into their build script. This requires the addition of an &lt;span class="codeInline"&gt;&amp;lt;Import/&amp;gt;&lt;/span&gt; element in the MSBuild file. For example, the ConsoleApplication.csproj file includes this:&lt;br /&gt;&lt;pre&gt;
&amp;lt;Import Project=&amp;quot;..\Lib\Gauntlet\Gauntlet.targets&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Define Templates
&lt;/h3&gt;Next, add a template to your project. If you’re using the NVelocity output generator (more on this later) then the template just needs to be a text file that contains an NVelocity template. The sample project contains a file called &lt;i&gt;GeneratedEnum.template&lt;/i&gt;, which is responsible for converting the input into an enumeration. The contents are as follows:&lt;br /&gt;&lt;pre&gt;
namespace ConsoleApplication
{
	public enum GeneratedEnum
	{
		#foreach ($member in $GeneratedEnum.Members.Member)
			$member.Name,
		#end
	}
}
&lt;/pre&gt;&lt;h3&gt;
Define Input File
&lt;/h3&gt;Now that we have a template, we need to add a file to serve as input to the code generation process. In this case, we’re using Gauntlet’s built-in XML input translator, so the input file – which I called &lt;i&gt;GeneratedEnum.input&lt;/i&gt; – is in an XML format. The contents of this file are:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;GeneratedEnum&amp;gt;
	&amp;lt;Members&amp;gt;
		&amp;lt;Member Name=&amp;quot;One&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Two&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Three&amp;quot;/&amp;gt;
	&amp;lt;/Members&amp;gt;
&amp;lt;/GeneratedEnum&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Generate the Output File
&lt;/h3&gt;Now that we have both template and input files, we need to tie the two together to produce the output file. To do this, we need to edit the project file manually. Open the project file and locate the input file’s entry. Change its type from &lt;span class="codeInline"&gt;None&lt;/span&gt; to &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot; /&amp;gt;
&lt;/pre&gt;Next, include the details of the template file, output file, input translator, and output generator inside the item definition:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot;&amp;gt;
	&amp;lt;TemplateFile&amp;gt;GeneratedEnum.template&amp;lt;/TemplateFile&amp;gt;
	&amp;lt;OutputFile&amp;gt;GeneratedEnum.g.cs&amp;lt;/OutputFile&amp;gt;
	&amp;lt;InputTranslator&amp;gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator, Kent.Boogaart.Gauntlet&amp;lt;/InputTranslator&amp;gt;
	&amp;lt;OutputGenerator&amp;gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator, Kent.Boogaart.Gauntlet&amp;lt;/OutputGenerator&amp;gt;
&amp;lt;/GeneratedItem&amp;gt;
&lt;/pre&gt;Without this information, the build process will fail with an appropriate error. That’s because Gauntlet attempts to process any files that are &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;s.&lt;br /&gt;&lt;h3&gt;
Include the Output File
&lt;/h3&gt;Once the above step is complete, build your project. All being well, you should see the output file in your project’s folder. Note that the build may fail, but the output file should still be generated. That’s because the output file has not yet been included into your project, and the &lt;span class="codeInline"&gt;Program&lt;/span&gt; class is assuming the existence of a &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt; type, which is defined by the output file.&lt;br /&gt; &lt;br /&gt;An easy way to include the output file in the solution is from Visual Studio’s solution explorer. First, click show all files for the project (the highlighted icon below):&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34810" alt="ShowAllFiles.png" /&gt;&lt;br /&gt;You will then see the &lt;i&gt;GeneratedEnum.g.cs&lt;/i&gt; file:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34811" alt="ShowAllFiles2.png" /&gt;&lt;br /&gt;Right-click the file and choose &lt;i&gt;Include In Project&lt;/i&gt;:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Gauntlet&amp;amp;DownloadId=34809" alt="IncludeInProject.png" /&gt;&lt;br /&gt;Now the output file is included in the project. If you execute the project, you should see all the members of the enumeration listed. Try playing with the input file and re-executing the application.&lt;br /&gt;&lt;h2&gt;
Out-of-the-box Functionality
&lt;/h2&gt;This section discusses the functionality that Gauntlet provides out-of-the-box.&lt;br /&gt;&lt;h3&gt;
XML Input Translator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator&lt;/span&gt; class is an input translator that takes any XML document and places in the current context for consumption by the output generator. It uses the root of the XML document as a key under which the XML is stored. From there, it permits a simple property syntax to navigate the XML document.&lt;br /&gt; &lt;br /&gt;For example, suppose you have the following XML input:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;BusinessObject ClassName=&amp;quot;Customer&amp;quot; Namespace=&amp;quot;BusinessObjects&amp;quot;&amp;gt;
	&amp;lt;Properties&amp;gt;
		&amp;lt;Property Name=&amp;quot;Name&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;DOB&amp;quot; Type=&amp;quot;DateTime&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;Address&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
	&amp;lt;/Properties&amp;gt;
&amp;lt;/BusinessObject&amp;gt;
&lt;/pre&gt;Using the NVelocity output generator (see below), the class name can be accessed via the syntax &lt;span class="codeInline"&gt;$BusinessObject.ClassName&lt;/span&gt; and the collection of properties can be obtained via the syntax &lt;span class="codeInline"&gt;$BusinessObject.Properties.Property&lt;/span&gt;.&lt;br /&gt;&lt;h3&gt;
NVelocity Output Generator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator&lt;/span&gt; class is an output generator that assumes the template file is an NVelocity template. It takes all items in the Gauntlet context’s state bag and passes them into the NVelocity context for the template to consume.&lt;br /&gt;&lt;h3&gt;
Timestamp Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.TimestampRegenerationPolicy&lt;/span&gt; class is used by default, and uses the timestamps of the files to determine whether code generation is required.&lt;br /&gt;&lt;h3&gt;
Forced Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.ForcedRegenerationPolicy&lt;/span&gt; class is a regeneration policy that always generates code, regardless of whether the generation is actually necessary. It should be used with caution.&lt;br /&gt;&lt;h3&gt;
Default Context
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.Context&lt;/span&gt; is a base context implementation that is used unless otherwise specified. It includes properties to get the various files included in the generation, a timestamp for when the generation process began, a log, and a state bag.&lt;br /&gt;
&lt;/div&gt;</description><author>kentcb</author><pubDate>Sun, 18 May 2008 14:56:34 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: User Documentation 20080518025634P</guid></item><item><title>UPDATED WIKI: User Documentation</title><link>http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=User Documentation&amp;version=3</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
Introduction
&lt;/h1&gt;Gauntlet is a .NET code generation tool with emphases on simplicity, extensibility, and seamless integration with the .NET build system. It is designed to slot right into your build process, alleviating you of the need to run an external tool for code generation.&lt;br /&gt;&lt;h2&gt;
Why Another Code Generation Tool?
&lt;/h2&gt;There is a plethora of code generation tools available for .NET, some commercial and some – like Gauntlet – open source. Why is there a need for another?&lt;br /&gt; &lt;br /&gt;Gauntlet differs from other code generators by integrating seamlessly with .NET’s build platform, MSBuild. What this means is that when you change an input or template file, you simply build your project to have the corresponding output generated. This works the same whether you’re building from the command line or from within Visual Studio. There is no need to start up an external tool, or even to know that Gauntlet is being used to generate the output.&lt;br /&gt; &lt;br /&gt;Gauntlet also provides extensibility points for the entire generation process. If you need to support a custom input format, you can. If you need to integrate with a proprietary template engine, you can.&lt;br /&gt;&lt;h2&gt;
How Might I Use Gauntlet?
&lt;/h2&gt;The possibilities really are endless, but here are some examples to illustrate:&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Ever wanted more control over the web service clients that Visual Studio generates for web references? Using Gauntlet you could write your own template and take full control of the code, using the WSDL as the input to the generation process.&lt;/li&gt;&lt;li&gt;Most domain layers are very repetitive: they’re essentially a bunch of data classes with some business logic sprinkled throughout. Using Gauntlet, you could define a template for your domain objects and save a heap of time and maintenance cost. Your input file could be a simple XML structure defining the properties of your domain object. The template could contain the logic to generate fields, properties, property change notifications (for data binding), custom serialization logic (to increase serialization speeds) etcetera.&lt;/li&gt;&lt;li&gt;Ever had to work with a framework that imposes ridiculous restrictions that stop you from using inheritance to factor out common functionality? &lt;b&gt;cough&lt;/b&gt; MAF &lt;b&gt;cough&lt;/b&gt; Well, you could succumb to the evil will of the framework and write the same code a hundred times, or you could write a template and generate that code instead.&lt;/li&gt;
&lt;/ul&gt;&lt;h1&gt;
Design
&lt;/h1&gt;&lt;h2&gt;
Assemblies
&lt;/h2&gt;Gauntlet’s key components are divided into two assemblies: &lt;i&gt;Kent.Boogaart.Gauntlet&lt;/i&gt; and &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild&lt;/i&gt;. The former defines the core Gauntlet interfaces and provides some generic implementations of these interfaces. The latter provides support for incorporating Gauntlet into MSBuild scripts.&lt;br /&gt; &lt;br /&gt;If you’re writing custom components to hook into the Gauntlet generation process, you’ll need to reference &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;. If you’re simply using Gauntlet in your build process, both assemblies are used and the instructions for setting up can be found &lt;b&gt;here&lt;/b&gt;.&lt;br /&gt;&lt;h2&gt;
Generation Process
&lt;/h2&gt;Gauntlet’s code generation process is depicted below:&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:CodeGenerationProcess.png]&lt;br /&gt;The input and template files are fed into a regeneration policy. The regeneration policy decides whether the generation should continue or be skipped altogether. If continued, an input translator is used to translate the input file into something that can be consumed by the output generator. The output generator is responsible for converting the translated input into the final output file. A context is passed through the whole generation process. This context can be used by the various components of the pipeline to make decisions or store state.&lt;br /&gt; &lt;br /&gt;All pipeline components are extensible. You can provide your own regeneration policy, input translator, output generator, or even a custom context implementation. Gauntlet comes with various useful implementations of all of these components and it will often be unnecessary for you to write your own, but the extensibility points are there if required.&lt;br /&gt; &lt;br /&gt;Missing from the above diagram is a depiction of logging. The context passed through the generation process includes a property of type &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.ILog&lt;/span&gt;. This interface defines methods for logging messages and exceptions, and can be used by components in the generation pipeline. The particular implementation of ILog present will determine how log entries are manifested. When using Gauntlet from within your MSBuild script, log statements will flow through to the build output. Therefore, if an error is logged, it will appear as an error when building from within Visual Studio.&lt;br /&gt;&lt;h1&gt;
Using Gauntlet
&lt;/h1&gt;&lt;h2&gt;
Integrating With MSBuild
&lt;/h2&gt;In order to integrate Gauntlet into your build process, you need to follow a number of simple steps. As of version 1.0 of Gauntlet, there is no Visual Studio integration. Therefore, these steps must be performed manually. Note that you can still build from Visual Studio (since Visual Studio uses MSBuild behind the scenes). However, there is no Visual Studio add-in to perform the steps below automatically.&lt;br /&gt; &lt;br /&gt;There is a sample solution called &lt;i&gt;IntegratingGauntletWithMSBuild.sln&lt;/i&gt; that shows the results of all these steps being applied. Inside this solution there is a single project called &lt;i&gt;ConsoleApplication&lt;/i&gt;, which uses Gauntlet to generate an enumeration called &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt;. When the application is executed, it outputs the members of this enumeration to the console.&lt;br /&gt;&lt;h3&gt;
Ensure Gauntlet Files are Available to Build Process
&lt;/h3&gt;First of all, make sure that the Gauntlet files are available to your build process. An easy way to do this is to place them under a Lib (or similar) directory in your project’s folder structure. I normally have a Lib folder to store referenced assemblies anyway, so I just create a Lib\Gauntlet folder to store the Gauntlet assemblies. You can see this in the sample:&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:FolderStructure.png]&lt;br /&gt;There are a number of files that need to be placed in this folder: &lt;i&gt;Kent.Boogaart.HelperTrinity.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild.dll&lt;/i&gt;, &lt;i&gt;Gauntlet.targets&lt;/i&gt;, and &lt;i&gt;NVelocity.dll&lt;/i&gt;:&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:GauntletFiles.png]&lt;br /&gt;&lt;h3&gt;
Import Gauntlet into Relevant Project(s)
&lt;/h3&gt;The next step is to determine which projects in your solution need to use Gauntlet, and to import Gauntlet targets into their build script. This requires the addition of an &lt;span class="codeInline"&gt;&amp;lt;Import/&amp;gt;&lt;/span&gt; element in the MSBuild file. For example, the ConsoleApplication.csproj file includes this:&lt;br /&gt;&lt;pre&gt;
&amp;lt;Import Project=&amp;quot;..\Lib\Gauntlet\Gauntlet.targets&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Define Templates
&lt;/h3&gt;Next, add a template to your project. If you’re using the NVelocity output generator (more on this later) then the template just needs to be a text file that contains an NVelocity template. The sample project contains a file called &lt;i&gt;GeneratedEnum.template&lt;/i&gt;, which is responsible for converting the input into an enumeration. The contents are as follows:&lt;br /&gt;&lt;pre&gt;
namespace ConsoleApplication
{
	public enum GeneratedEnum
	{
		#foreach ($member in $GeneratedEnum.Members.Member)
			$member.Name,
		#end
	}
}
&lt;/pre&gt;&lt;h3&gt;
Define Input File
&lt;/h3&gt;Now that we have a template, we need to add a file to serve as input to the code generation process. In this case, we’re using Gauntlet’s built-in XML input translator, so the input file – which I called &lt;i&gt;GeneratedEnum.input&lt;/i&gt; – is in an XML format. The contents of this file are:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;GeneratedEnum&amp;gt;
	&amp;lt;Members&amp;gt;
		&amp;lt;Member Name=&amp;quot;One&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Two&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Three&amp;quot;/&amp;gt;
	&amp;lt;/Members&amp;gt;
&amp;lt;/GeneratedEnum&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Generate the Output File
&lt;/h3&gt;Now that we have both template and input files, we need to tie the two together to produce the output file. To do this, we need to edit the project file manually. Open the project file and locate the input file’s entry. Change its type from &lt;span class="codeInline"&gt;None&lt;/span&gt; to &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot; /&amp;gt;
&lt;/pre&gt;Next, include the details of the template file, output file, input translator, and output generator inside the item definition:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot;&amp;gt;
	&amp;lt;TemplateFile&amp;gt;GeneratedEnum.template&amp;lt;/TemplateFile&amp;gt;
	&amp;lt;OutputFile&amp;gt;GeneratedEnum.g.cs&amp;lt;/OutputFile&amp;gt;
	&amp;lt;InputTranslator&amp;gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator, Kent.Boogaart.Gauntlet&amp;lt;/InputTranslator&amp;gt;
	&amp;lt;OutputGenerator&amp;gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator, Kent.Boogaart.Gauntlet&amp;lt;/OutputGenerator&amp;gt;
&amp;lt;/GeneratedItem&amp;gt;
&lt;/pre&gt;Without this information, the build process will fail with an appropriate error. That’s because Gauntlet attempts to process any files that are &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;s.&lt;br /&gt;&lt;h3&gt;
Include the Output File
&lt;/h3&gt;Once the above step is complete, build your project. All being well, you should see the output file in your project’s folder. Note that the build may fail, but the output file should still be generated. That’s because the output file has not yet been included into your project, and the &lt;span class="codeInline"&gt;Program&lt;/span&gt; class is assuming the existence of a &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt; type, which is defined by the output file.&lt;br /&gt; &lt;br /&gt;An easy way to include the output file in the solution is from Visual Studio’s solution explorer. First, click show all files for the project (the highlighted icon below):&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:ShowAllFiles.png]&lt;br /&gt;You will then see the &lt;i&gt;GeneratedEnum.g.cs&lt;/i&gt; file:&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:ShowAllFiles2.png]&lt;br /&gt;Right-click the file and choose &lt;i&gt;Include In Project&lt;/i&gt;:&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:IncludeInProject.png]&lt;br /&gt;Now the output file is included in the project. If you execute the project, you should see all the members of the enumeration listed. Try playing with the input file and re-executing the application.&lt;br /&gt;&lt;h2&gt;
Out-of-the-box Functionality
&lt;/h2&gt;This section discusses the functionality that Gauntlet provides out-of-the-box.&lt;br /&gt;&lt;h3&gt;
XML Input Translator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator&lt;/span&gt; class is an input translator that takes any XML document and places in the current context for consumption by the output generator. It uses the root of the XML document as a key under which the XML is stored. From there, it permits a simple property syntax to navigate the XML document.&lt;br /&gt; &lt;br /&gt;For example, suppose you have the following XML input:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;BusinessObject ClassName=&amp;quot;Customer&amp;quot; Namespace=&amp;quot;BusinessObjects&amp;quot;&amp;gt;
	&amp;lt;Properties&amp;gt;
		&amp;lt;Property Name=&amp;quot;Name&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;DOB&amp;quot; Type=&amp;quot;DateTime&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;Address&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
	&amp;lt;/Properties&amp;gt;
&amp;lt;/BusinessObject&amp;gt;
&lt;/pre&gt;Using the NVelocity output generator (see below), the class name can be accessed via the syntax &lt;span class="codeInline"&gt;$BusinessObject.ClassName&lt;/span&gt; and the collection of properties can be obtained via the syntax &lt;span class="codeInline"&gt;$BusinessObject.Properties.Property&lt;/span&gt;.&lt;br /&gt;&lt;h3&gt;
NVelocity Output Generator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator&lt;/span&gt; class is an output generator that assumes the template file is an NVelocity template. It takes all items in the Gauntlet context’s state bag and passes them into the NVelocity context for the template to consume.&lt;br /&gt;&lt;h3&gt;
Timestamp Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.TimestampRegenerationPolicy&lt;/span&gt; class is used by default, and uses the timestamps of the files to determine whether code generation is required.&lt;br /&gt;&lt;h3&gt;
Forced Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.ForcedRegenerationPolicy&lt;/span&gt; class is a regeneration policy that always generates code, regardless of whether the generation is actually necessary. It should be used with caution.&lt;br /&gt;&lt;h3&gt;
Default Context
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.Context&lt;/span&gt; is a base context implementation that is used unless otherwise specified. It includes properties to get the various files included in the generation, a timestamp for when the generation process began, a log, and a state bag.&lt;br /&gt;
&lt;/div&gt;</description><author>kentcb</author><pubDate>Sun, 18 May 2008 14:53:59 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: User Documentation 20080518025359P</guid></item><item><title>UPDATED WIKI: User Documentation</title><link>http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=User Documentation&amp;version=2</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
Introduction
&lt;/h1&gt;Gauntlet is a .NET code generation tool with emphases on simplicity, extensibility, and seamless integration with the .NET build system. It is designed to slot right into your build process, alleviating you of the need to run an external tool for code generation.&lt;br /&gt;&lt;h2&gt;
Why Another Code Generation Tool?
&lt;/h2&gt;There is a plethora of code generation tools available for .NET, some commercial and some – like Gauntlet – open source. Why is there a need for another?&lt;br /&gt; &lt;br /&gt;Gauntlet differs from other code generators by integrating seamlessly with .NET’s build platform, MSBuild. What this means is that when you change an input or template file, you simply build your project to have the corresponding output generated. This works the same whether you’re building from the command line or from within Visual Studio. There is no need to start up an external tool, or even to know that Gauntlet is being used to generate the output.&lt;br /&gt; &lt;br /&gt;Gauntlet also provides extensibility points for the entire generation process. If you need to support a custom input format, you can. If you need to integrate with a proprietary template engine, you can.&lt;br /&gt;&lt;h2&gt;
How Might I Use Gauntlet?
&lt;/h2&gt;The possibilities really are endless, but here are some examples to illustrate:&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Ever wanted more control over the web service clients that Visual Studio generates for web references? Using Gauntlet you could write your own template and take full control of the code, using the WSDL as the input to the generation process.&lt;/li&gt;&lt;li&gt;Most domain layers are very repetitive: they’re essentially a bunch of data classes with some business logic sprinkled throughout. Using Gauntlet, you could define a template for your domain objects and save a heap of time and maintenance cost. Your input file could be a simple XML structure defining the properties of your domain object. The template could contain the logic to generate fields, properties, property change notifications (for data binding), custom serialization logic (to increase serialization speeds) etcetera.&lt;/li&gt;&lt;li&gt;Ever had to work with a framework that imposes ridiculous restrictions that stop you from using inheritance to factor out common functionality? &lt;b&gt;cough&lt;/b&gt; MAF &lt;b&gt;cough&lt;/b&gt; Well, you could succumb to the evil will of the framework and write the same code a hundred times, or you could write a template and generate that code instead.&lt;/li&gt;
&lt;/ul&gt;&lt;h1&gt;
Design
&lt;/h1&gt;&lt;h2&gt;
Assemblies
&lt;/h2&gt;Gauntlet’s key components are divided into two assemblies: &lt;i&gt;Kent.Boogaart.Gauntlet&lt;/i&gt; and &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild&lt;/i&gt;. The former defines the core Gauntlet interfaces and provides some generic implementations of these interfaces. The latter provides support for incorporating Gauntlet into MSBuild scripts.&lt;br /&gt; &lt;br /&gt;If you’re writing custom components to hook into the Gauntlet generation process, you’ll need to reference &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;. If you’re simply using Gauntlet in your build process, both assemblies are used and the instructions for setting up can be found &lt;b&gt;here&lt;/b&gt;.&lt;br /&gt;&lt;h2&gt;
Generation Process
&lt;/h2&gt;Gauntlet’s code generation process is depicted below:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;The input and template files are fed into a regeneration policy. The regeneration policy decides whether the generation should continue or be skipped altogether. If continued, an input translator is used to translate the input file into something that can be consumed by the output generator. The output generator is responsible for converting the translated input into the final output file. A context is passed through the whole generation process. This context can be used by the various components of the pipeline to make decisions or store state.&lt;br /&gt; &lt;br /&gt;All pipeline components are extensible. You can provide your own regeneration policy, input translator, output generator, or even a custom context implementation. Gauntlet comes with various useful implementations of all of these components and it will often be unnecessary for you to write your own, but the extensibility points are there if required.&lt;br /&gt; &lt;br /&gt;Missing from the above diagram is a depiction of logging. The context passed through the generation process includes a property of type &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.ILog&lt;/span&gt;. This interface defines methods for logging messages and exceptions, and can be used by components in the generation pipeline. The particular implementation of ILog present will determine how log entries are manifested. When using Gauntlet from within your MSBuild script, log statements will flow through to the build output. Therefore, if an error is logged, it will appear as an error when building from within Visual Studio.&lt;br /&gt;&lt;h1&gt;
Using Gauntlet
&lt;/h1&gt;&lt;h2&gt;
Integrating With MSBuild
&lt;/h2&gt;In order to integrate Gauntlet into your build process, you need to follow a number of simple steps. As of version 1.0 of Gauntlet, there is no Visual Studio integration. Therefore, these steps must be performed manually. Note that you can still build from Visual Studio (since Visual Studio uses MSBuild behind the scenes). However, there is no Visual Studio add-in to perform the steps below automatically.&lt;br /&gt; &lt;br /&gt;There is a sample solution called &lt;i&gt;IntegratingGauntletWithMSBuild.sln&lt;/i&gt; that shows the results of all these steps being applied. Inside this solution there is a single project called &lt;i&gt;ConsoleApplication&lt;/i&gt;, which uses Gauntlet to generate an enumeration called &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt;. When the application is executed, it outputs the members of this enumeration to the console.&lt;br /&gt;&lt;h3&gt;
Ensure Gauntlet Files are Available to Build Process
&lt;/h3&gt;First of all, make sure that the Gauntlet files are available to your build process. An easy way to do this is to place them under a Lib (or similar) directory in your project’s folder structure. I normally have a Lib folder to store referenced assemblies anyway, so I just create a Lib\Gauntlet folder to store the Gauntlet assemblies. You can see this in the sample:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;There are a number of files that need to be placed in this folder: &lt;i&gt;Kent.Boogaart.HelperTrinity.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild.dll&lt;/i&gt;, &lt;i&gt;Gauntlet.targets&lt;/i&gt;, and &lt;i&gt;NVelocity.dll&lt;/i&gt;:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;
Import Gauntlet into Relevant Project(s)
&lt;/h3&gt;The next step is to determine which projects in your solution need to use Gauntlet, and to import Gauntlet targets into their build script. This requires the addition of an &lt;span class="codeInline"&gt;&amp;lt;Import/&amp;gt;&lt;/span&gt; element in the MSBuild file. For example, the ConsoleApplication.csproj file includes this:&lt;br /&gt;&lt;pre&gt;
&amp;lt;Import Project=&amp;quot;..\Lib\Gauntlet\Gauntlet.targets&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Define Templates
&lt;/h3&gt;Next, add a template to your project. If you’re using the NVelocity output generator (more on this later) then the template just needs to be a text file that contains an NVelocity template. The sample project contains a file called &lt;i&gt;GeneratedEnum.template&lt;/i&gt;, which is responsible for converting the input into an enumeration. The contents are as follows:&lt;br /&gt;&lt;pre&gt;
namespace ConsoleApplication
{
	public enum GeneratedEnum
	{
		#foreach ($member in $GeneratedEnum.Members.Member)
			$member.Name,
		#end
	}
}
&lt;/pre&gt;&lt;h3&gt;
Define Input File
&lt;/h3&gt;Now that we have a template, we need to add a file to serve as input to the code generation process. In this case, we’re using Gauntlet’s built-in XML input translator, so the input file – which I called &lt;i&gt;GeneratedEnum.input&lt;/i&gt; – is in an XML format. The contents of this file are:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;GeneratedEnum&amp;gt;
	&amp;lt;Members&amp;gt;
		&amp;lt;Member Name=&amp;quot;One&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Two&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Three&amp;quot;/&amp;gt;
	&amp;lt;/Members&amp;gt;
&amp;lt;/GeneratedEnum&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Generate the Output File
&lt;/h3&gt;Now that we have both template and input files, we need to tie the two together to produce the output file. To do this, we need to edit the project file manually. Open the project file and locate the input file’s entry. Change its type from &lt;span class="codeInline"&gt;None&lt;/span&gt; to &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot; /&amp;gt;
&lt;/pre&gt;Next, include the details of the template file, output file, input translator, and output generator inside the item definition:&lt;br /&gt;&lt;pre&gt;
&amp;lt;GeneratedItem Include=&amp;quot;GeneratedEnum.input&amp;quot;&amp;gt;
	&amp;lt;TemplateFile&amp;gt;GeneratedEnum.template&amp;lt;/TemplateFile&amp;gt;
	&amp;lt;OutputFile&amp;gt;GeneratedEnum.g.cs&amp;lt;/OutputFile&amp;gt;
	&amp;lt;InputTranslator&amp;gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator, Kent.Boogaart.Gauntlet&amp;lt;/InputTranslator&amp;gt;
	&amp;lt;OutputGenerator&amp;gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator, Kent.Boogaart.Gauntlet&amp;lt;/OutputGenerator&amp;gt;
&amp;lt;/GeneratedItem&amp;gt;
&lt;/pre&gt;Without this information, the build process will fail with an appropriate error. That’s because Gauntlet attempts to process any files that are &lt;span class="codeInline"&gt;GeneratedItem&lt;/span&gt;s.&lt;br /&gt;&lt;h3&gt;
Include the Output File
&lt;/h3&gt;Once the above step is complete, build your project. All being well, you should see the output file in your project’s folder. Note that the build may fail, but the output file should still be generated. That’s because the output file has not yet been included into your project, and the &lt;span class="codeInline"&gt;Program&lt;/span&gt; class is assuming the existence of a &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt; type, which is defined by the output file.&lt;br /&gt; &lt;br /&gt;An easy way to include the output file in the solution is from Visual Studio’s solution explorer. First, click show all files for the project (the highlighted icon below):&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;You will then see the &lt;i&gt;GeneratedEnum.g.cs&lt;/i&gt; file:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;Right-click the file and choose &lt;i&gt;Include In Project&lt;/i&gt;:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;Now the output file is included in the project. If you execute the project, you should see all the members of the enumeration listed. Try playing with the input file and re-executing the application.&lt;br /&gt;&lt;h2&gt;
Out-of-the-box Functionality
&lt;/h2&gt;This section discusses the functionality that Gauntlet provides out-of-the-box.&lt;br /&gt;&lt;h3&gt;
XML Input Translator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.InputTranslators.XmlInputTranslator&lt;/span&gt; class is an input translator that takes any XML document and places in the current context for consumption by the output generator. It uses the root of the XML document as a key under which the XML is stored. From there, it permits a simple property syntax to navigate the XML document.&lt;br /&gt; &lt;br /&gt;For example, suppose you have the following XML input:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;BusinessObject ClassName=&amp;quot;Customer&amp;quot; Namespace=&amp;quot;BusinessObjects&amp;quot;&amp;gt;
	&amp;lt;Properties&amp;gt;
		&amp;lt;Property Name=&amp;quot;Name&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;DOB&amp;quot; Type=&amp;quot;DateTime&amp;quot;/&amp;gt;
		&amp;lt;Property Name=&amp;quot;Address&amp;quot; Type=&amp;quot;string&amp;quot;/&amp;gt;
	&amp;lt;/Properties&amp;gt;
&amp;lt;/BusinessObject&amp;gt;
&lt;/pre&gt;Using the NVelocity output generator (see below), the class name can be accessed via the syntax &lt;span class="codeInline"&gt;$BusinessObject.ClassName&lt;/span&gt; and the collection of properties can be obtained via the syntax &lt;span class="codeInline"&gt;$BusinessObject.Properties.Property&lt;/span&gt;.&lt;br /&gt;&lt;h3&gt;
NVelocity Output Generator
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.OutputGenerators.NVelocityOutputGenerator&lt;/span&gt; class is an output generator that assumes the template file is an NVelocity template. It takes all items in the Gauntlet context’s state bag and passes them into the NVelocity context for the template to consume.&lt;br /&gt;&lt;h3&gt;
Timestamp Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.TimestampRegenerationPolicy&lt;/span&gt; class is used by default, and uses the timestamps of the files to determine whether code generation is required.&lt;br /&gt;&lt;h3&gt;
Forced Regeneration Policy
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.RegenerationPolicies.ForcedRegenerationPolicy&lt;/span&gt; class is a regeneration policy that always generates code, regardless of whether the generation is actually necessary. It should be used with caution.&lt;br /&gt;&lt;h3&gt;
Default Context
&lt;/h3&gt;The &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.Context&lt;/span&gt; is a base context implementation that is used unless otherwise specified. It includes properties to get the various files included in the generation, a timestamp for when the generation process began, a log, and a state bag.&lt;br /&gt;
&lt;/div&gt;</description><author>kentcb</author><pubDate>Sun, 18 May 2008 14:49:17 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: User Documentation 20080518024917P</guid></item><item><title>UPDATED WIKI: User Documentation</title><link>http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=User Documentation&amp;version=1</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
Introduction
&lt;/h1&gt;Gauntlet is a .NET code generation tool with emphases on simplicity, extensibility, and seamless integration with the .NET build system. It is designed to slot right into your build process, alleviating you of the need to run an external tool for code generation.&lt;br /&gt;&lt;h2&gt;
Why Another Code Generation Tool?
&lt;/h2&gt;There is a plethora of code generation tools available for .NET, some commercial and some – like Gauntlet – open source. Why is there a need for another?&lt;br /&gt; &lt;br /&gt;Gauntlet differs from other code generators by integrating seamlessly with .NET’s build platform, MSBuild. What this means is that when you change an input or template file, you simply build your project to have the corresponding output generated. This works the same whether you’re building from the command line or from within Visual Studio. There is no need to start up an external tool, or even to know that Gauntlet is being used to generate the output.&lt;br /&gt; &lt;br /&gt;Gauntlet also provides extensibility points for the entire generation process. If you need to support a custom input format, you can. If you need to integrate with a proprietary template engine, you can.&lt;br /&gt;&lt;h2&gt;
How Might I Use Gauntlet?
&lt;/h2&gt;The possibilities really are endless, but here are some examples to illustrate:&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Ever wanted more control over the web service clients that Visual Studio generates for web references? Using Gauntlet you could write your own template and take full control of the code, using the WSDL as the input to the generation process.&lt;/li&gt;&lt;li&gt;Most domain layers are very repetitive: they’re essentially a bunch of data classes with some business logic sprinkled throughout. Using Gauntlet, you could define a template for your domain objects and save a heap of time and maintenance cost. Your input file could be a simple XML structure defining the properties of your domain object. The template could contain the logic to generate fields, properties, property change notifications (for data binding), custom serialization logic (to increase serialization speeds) etcetera.&lt;/li&gt;&lt;li&gt;Ever had to work with a framework that imposes ridiculous restrictions that stop you from using inheritance to factor out common functionality? &lt;b&gt;cough&lt;/b&gt; MAF &lt;b&gt;cough&lt;/b&gt; Well, you could succumb to the evil will of the framework and write the same code a hundred times, or you could write a template and generate that code instead.&lt;/li&gt;
&lt;/ul&gt;&lt;h1&gt;
Design
&lt;/h1&gt;&lt;h2&gt;
Assemblies
&lt;/h2&gt;Gauntlet’s key components are divided into two assemblies: &lt;i&gt;Kent.Boogaart.Gauntlet&lt;/i&gt; and &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild&lt;/i&gt;. The former defines the core Gauntlet interfaces and provides some generic implementations of these interfaces. The latter provides support for incorporating Gauntlet into MSBuild scripts.&lt;br /&gt; &lt;br /&gt;If you’re writing custom components to hook into the Gauntlet generation process, you’ll need to reference &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;. If you’re simply using Gauntlet in your build process, both assemblies are used and the instructions for setting up can be found &lt;b&gt;here&lt;/b&gt;.&lt;br /&gt;&lt;h2&gt;
Generation Process
&lt;/h2&gt;Gauntlet’s code generation process is depicted below:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;The input and template files are fed into a regeneration policy. The regeneration policy decides whether the generation should continue or be skipped altogether. If continued, an input translator is used to translate the input file into something that can be consumed by the output generator. The output generator is responsible for converting the translated input into the final output file. A context is passed through the whole generation process. This context can be used by the various components of the pipeline to make decisions or store state.&lt;br /&gt; &lt;br /&gt;All pipeline components are extensible. You can provide your own regeneration policy, input translator, output generator, or even a custom context implementation. Gauntlet comes with various useful implementations of all of these components and it will often be unnecessary for you to write your own, but the extensibility points are there if required.&lt;br /&gt; &lt;br /&gt;Missing from the above diagram is a depiction of logging. The context passed through the generation process includes a property of type &lt;span class="codeInline"&gt;Kent.Boogaart.Gauntlet.ILog&lt;/span&gt;. This interface defines methods for logging messages and exceptions, and can be used by components in the generation pipeline. The particular implementation of ILog present will determine how log entries are manifested. When using Gauntlet from within your MSBuild script, log statements will flow through to the build output. Therefore, if an error is logged, it will appear as an error when building from within Visual Studio.&lt;br /&gt;&lt;h1&gt;
Using Gauntlet
&lt;/h1&gt;&lt;h2&gt;
Integrating With MSBuild
&lt;/h2&gt;In order to integrate Gauntlet into your build process, you need to follow a number of simple steps. As of version 1.0 of Gauntlet, there is no Visual Studio integration. Therefore, these steps must be performed manually. Note that you can still build from Visual Studio (since Visual Studio uses MSBuild behind the scenes). However, there is no Visual Studio add-in to perform the steps below automatically.&lt;br /&gt; &lt;br /&gt;There is a sample solution called &lt;i&gt;IntegratingGauntletWithMSBuild.sln&lt;/i&gt; that shows the results of all these steps being applied. Inside this solution there is a single project called &lt;i&gt;ConsoleApplication&lt;/i&gt;, which uses Gauntlet to generate an enumeration called &lt;span class="codeInline"&gt;GeneratedEnum&lt;/span&gt;. When the application is executed, it outputs the members of this enumeration to the console.&lt;br /&gt;&lt;h3&gt;
Ensure Gauntlet Files are Available to Build Process
&lt;/h3&gt;First of all, make sure that the Gauntlet files are available to your build process. An easy way to do this is to place them under a Lib (or similar) directory in your project’s folder structure. I normally have a Lib folder to store referenced assemblies anyway, so I just create a Lib\Gauntlet folder to store the Gauntlet assemblies. You can see this in the sample:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;There are a number of files that need to be placed in this folder: &lt;i&gt;Kent.Boogaart.HelperTrinity.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.dll&lt;/i&gt;, &lt;i&gt;Kent.Boogaart.Gauntlet.MSBuild.dll&lt;/i&gt;, &lt;i&gt;Gauntlet.targets&lt;/i&gt;, and &lt;i&gt;NVelocity.dll&lt;/i&gt;:&lt;br /&gt;&lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=IMAGE&amp;amp;referringTitle=User%20Documentation"&gt;IMAGE&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;
Import Gauntlet into Relevant Project(s)
&lt;/h3&gt;The next step is to determine which projects in your solution need to use Gauntlet, and to import Gauntlet targets into their build script. This requires the addition of an &lt;span class="codeInline"&gt;&amp;lt;Import/&amp;gt;&lt;/span&gt; element in the MSBuild file. For example, the ConsoleApplication.csproj file includes this:&lt;br /&gt;&lt;pre&gt;
&amp;lt;Import Project=&amp;quot;..\Lib\Gauntlet\Gauntlet.targets&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;h3&gt;
Define Templates
&lt;/h3&gt;Next, add a template to your project. If you’re using the NVelocity output generator (more on this later) then the template just needs to be a text file that contains an NVelocity template. The sample project contains a file called &lt;i&gt;GeneratedEnum.template&lt;/i&gt;, which is responsible for converting the input into an enumeration. The contents are as follows:&lt;br /&gt;&lt;pre&gt;
namespace ConsoleApplication
{
	public enum GeneratedEnum
	{
		#foreach ($member in $GeneratedEnum.Members.Member)
			$member.Name,
		#end
	}
}
&lt;/pre&gt;&lt;h3&gt;
Define Input File
&lt;/h3&gt;Now that we have a template, we need to add a file to serve as input to the code generation process. In this case, we’re using Gauntlet’s built-in XML input translator, so the input file – which I called &lt;i&gt;GeneratedEnum.input&lt;/i&gt; – is in an XML format. The contents of this file are:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
 
&amp;lt;GeneratedEnum&amp;gt;
	&amp;lt;Members&amp;gt;
		&amp;lt;Member Name=&amp;quot;One&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Two&amp;quot;/&amp;gt;
		&amp;lt;Member Name=&amp;quot;Three&amp;quot;/&amp;gt;
	&amp;lt;/Members&amp;gt;
&amp;lt;/GeneratedEnum&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;</description><author>kentcb</author><pubDate>Sun, 18 May 2008 14:44:01 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: User Documentation 20080518024401P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=Home&amp;version=2</link><description>&lt;div class="wikidoc"&gt;
Gauntlet is a .NET code generation tool. It slots into your MSBuild scripts and generates code as needed each time you build. Please see the &lt;a href="http://www.codeplex.com/Gauntlet/Wiki/View.aspx?title=User%20Documentation&amp;amp;referringTitle=Home"&gt;user documentation&lt;/a&gt; for more information. Complete API documentation is also available in the &lt;a href="http://www.codeplex.com/Gauntlet/Release/ProjectReleases.aspx" class="externalLink"&gt;releases&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; section.&lt;br /&gt;
&lt;/div&gt;</description><author>kentcb</author><pubDate>Sun, 18 May 2008 14:30:28 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080518023028P</guid></item></channel></rss>