<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Scripting &amp; Automation</title>
        <link>http://geekswithblogs.net/EltonStoneman/category/7945.aspx</link>
        <description>Simplifying repeatable tasks</description>
        <language>en-GB</language>
        <copyright>EltonStoneman</copyright>
        <managingEditor>elton.stoneman@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Sixeyed.Guidance.CodeGeneration: Technical Walkthrough</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/09/sixeyed.guidance.codegeneration-technical-walkthrough.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/03/07/code-generation-guidance-package.aspx"&gt;Code Generation Guidance Package&lt;/a&gt; on &lt;a href="http://www.codeplex.com/GAXCodeGeneration"&gt;CodePlex&lt;/a&gt; was designed to be extensible and reusable. There are three main C# projects, which isolate logic for code generation, and the UI and GAX components.  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sixeyed.CodeGeneration&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;This is the core project, defining how metadata is represented and retrieved, and defining configuration for code generation runs. Metadata is defined in terms of: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;A metadata source, which contains the logic for connecting to the source &lt;/li&gt;
    &lt;li&gt;A metadata provider, which uses the source to provide a list of available items, and to populate requested items &lt;/li&gt;
    &lt;li&gt;Metadata items, which are a representation of the metadata, typically using an appropriate .NET framework class &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Code generation and UI logic always works on the interfaces which define these components, and the relationships between them: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030909_1806_SixeyedGuid1.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;In the &lt;em&gt;Add Generated Items&lt;/em&gt; recipe, the available source types, sources and providers are populated from the collection of &lt;strong&gt;IMetadataSource&lt;/strong&gt; objects held in the static &lt;strong&gt;SourceContainer&lt;/strong&gt; class (additional sources can be added to the container at runtime using the &lt;em&gt;SourceAssemblyConfiguration&lt;/em&gt; recipe argument – described in &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/03/08/sixeyed.guidance.codegeneration-sample-package.aspx"&gt;Sixeyed.Guidance.CodeGeneration Sample Package&lt;/a&gt;). When a provider is selected, &lt;em&gt;GetItemNames&lt;/em&gt; is called to populate the list of available metadata items. When the selected items are iterated over in a code generation run, &lt;em&gt;GetItem&lt;/em&gt; is called and the populated &lt;strong&gt;IMetadataItem&lt;/strong&gt; is loaded as a property for the T4 template. The metadata item exposes the provider, and the provider exposes the source so the template can connect directly to the metadata if it needs to. &lt;/p&gt;
&lt;p&gt;Each metadata interface has an abstract base class which implements it and contains core logic. For a given source, there may be an additional base class which abstracts logic common to that type of source. In &lt;strong&gt;Sixeyed.CodeGeneration.Metadata.Database.Source&lt;/strong&gt;, &lt;strong&gt;DatabaseSource&lt;/strong&gt; contains logic for accessing ADO.NET data sources in terms of &lt;strong&gt;IDbConnection&lt;/strong&gt; and &lt;strong&gt;IDbCommand&lt;/strong&gt; objects; &lt;strong&gt;SqlServerSource&lt;/strong&gt; contains overriding logic to specify &lt;strong&gt;SqlConnection&lt;/strong&gt; and &lt;strong&gt;SqlCommand&lt;/strong&gt; usage – any additional database sources would do the same. Similarly for the SOAP metadata source, the logic for accessing WSDL is abstracted into a base class which may be used by other sources (e.g. a WCF specific source): &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030909_1806_SixeyedGuid2.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;IMetadataProvider&lt;/strong&gt; contains logic for accessing the source and retrieving a list of available items, and for populating a named item. The majority of logic is in the generic base class, so provider classes are quite simple. Simpler still are metadata item classes, which inherit the generic &lt;strong&gt;ItemBase&lt;/strong&gt; class, specifying the underlying type of the item (&lt;strong&gt;XmlSchema&lt;/strong&gt; in this case), without requiring any additional code. &lt;/p&gt;
&lt;p&gt;Logic for populating template properties and executing T4 templates is located in the Guidance project rather than the code generation project, as it is dependent on the specific T4 engine being used.  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sixeyed.CodeGeneration.UI&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;The UI project contains generic user controls which represent metadata selections, and expose various events to notify of selection changes. The Guidance package Wizard uses these components rather than defining its own UI – the controls from this assembly allow code generation to be configured and invoked from a different UI host. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sixeyed.Guidance.CodeGeneration &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This project defines the GAX package and links together the code generation and UI components. The Guidance package is quite straightforward – it contains a single class &lt;strong&gt;AddGeneratedItems&lt;/strong&gt; for the action of generating items from metadata and adding them to the selected project. The action expects &lt;em&gt;SourceConfiguration&lt;/em&gt;, &lt;em&gt;SelectedItems&lt;/em&gt; and &lt;em&gt;TemplateConfiguration&lt;/em&gt; arguments; it connects to the source, iterates over the selected items and executes the template for each item. &lt;/p&gt;
&lt;p&gt;To collect the argument values, there are custom wizard pages and value providers for each, allowing a recipe to provide ready-configured settings, or build a UI to gather them from the user: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Sixeyed.Guidance.CodeGeneration.CustomWizardPages&lt;/strong&gt;. The custom Wizard pages use the static &lt;strong&gt;Metadata &lt;/strong&gt;class to share state for the configured metadata source and provider. They override &lt;em&gt;IsDataValid&lt;/em&gt; to determine if the page has collected enough information for the Wizard to proceed and the base class provides &lt;em&gt;EnableNextStep&lt;/em&gt; which will advance the Wizard by enabling the Next or Finish button as appropriate. The base class will read the &lt;em&gt;SourceAssemblyConfiguration&lt;/em&gt; recipe argument if provided, and use it to add any extra metadata assemblies at runtime. &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Sixeyed.Guidance.CodeGeneration.ValueProviders&lt;/strong&gt;. The value provider classes are straightforward, reading optional arguments from the recipe and populating the relevant metadata settings. Custom recipes can specify value providers to load settings instead of Wizard pages, so the Wizard UI can be restricted. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;TODOs &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There are a couple of minor changes I'd like to make to the current codebase: &lt;/p&gt;
&lt;ul style="margin-left: 38pt;"&gt;
    &lt;li&gt;&lt;strong&gt;Sixeyed.Guidance.CodeGeneration.CustomWizardPages.SelectTemplate &lt;/strong&gt;defines its own UI, which should be moved to a user control in the UI project; &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Sixeyed.CodeGeneration.Generation.MemberName&lt;/strong&gt; contains methods for providing valid field and property names, but the Pascal and camel-case conversion is very basic; &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Sixeyed.CodeGeneration.UI.SourceUri&lt;/strong&gt; has some ugly hard-coding to decide which UI dialog it should show for different types of URI. It should be configurable, but I'm not happy moving it to an attribute of &lt;strong&gt;IMetadataSource&lt;/strong&gt;, as that brings the UI into the core project.  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And some additional metadata sources which I'll add at a future point – a Clipboard source providing access to clipboard data through text or XML providers, and a BizTalk source which will use the ExplorerOM for providers supplying application, group and instance information as metadata. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129942"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129942" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129942.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/09/sixeyed.guidance.codegeneration-technical-walkthrough.aspx</guid>
            <pubDate>Mon, 09 Mar 2009 23:05:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129942.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/09/sixeyed.guidance.codegeneration-technical-walkthrough.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129942.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Sixeyed.Guidance.CodeGeneration Sample Package</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/08/sixeyed.guidance.codegeneration-sample-package.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The basic &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2009/03/07/code-generation-guidance-package.aspx"&gt;Code Generation Guidance Package&lt;/a&gt; on &lt;a href="http://www.codeplex.com/GAXCodeGeneration"&gt;CodePlex&lt;/a&gt; comes with an additional sample Guidance package. This sample is intended to demonstrate how the functionality of the base package can be customised to create a project-specific Guidance package, where you can easily add tailored code generation recipes to your package. In the basic package are the Wizard steps necessary to configure ad-hoc code generation, but there are also ValueProviders which can read configuration from recipes without requiring the whole user interface. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Installation &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You'll need to modify the hard-coded paths and URIs in the sample package, so it doesn't come with an installed release. If you open the &lt;strong&gt;Sixeyed.Guidance.CodeGenerationSample&lt;/strong&gt; solution you'll see that it references the base &lt;strong&gt;Sixeyed.Guidance.CodeGeneration&lt;/strong&gt; and &lt;strong&gt;Sixeyed.CodeGeneration&lt;/strong&gt; assemblies. The sample contains a set of T4 templates in the &lt;em&gt;\Templates\Text&lt;/em&gt; directory, the XML configuration for the package and the XML includes for individual recipes. There's no additional code in the sample project, all the required functionality is in the referenced base package. &lt;/p&gt;
&lt;p&gt;Together with the GAX project, there's a database project which you can use to create a SQL Server database suitable for the data-bound recipes to run against. To install, run the &lt;em&gt;CreateDatabase&lt;/em&gt; script and then execute the SSIS package to populate data from the included Excel workbook (this is only necessary if you want to run the recipes as-is, otherwise you can modify the XML to use your own database). &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sample T4 Templates&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;There are T4 templates for each of the metadata providers in the base package. The scripts named &lt;em&gt;_Simple.tt&lt;/em&gt; are straightforward and begin with the name of the expected provider; to run them, you can use &lt;em&gt;Add Generated Items&lt;/em&gt; from the base package, select the relevant metadata and point to the template. To demonstrate more useful code generation, there are two more substantial templates: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;em&gt;ConfigurationSection.cs.tt&lt;/em&gt; – use the File source and the Text provider on this template. If you select &lt;em&gt;Configuration.txt&lt;/em&gt; (from the database project) as the source, the recipe will generate a typed configuration class, which has a static property to access the current config settings. The template can be easily extended to add a Default value for optional settings, and the same text file can be used to drive a different T4 template to generate the actual configuration settings; &lt;/li&gt;
    &lt;li&gt;&lt;em&gt;StoredProcedure.cs.tt&lt;/em&gt; – use the SQL Server database source and the Stored Procedure provider. Select a procedure and the recipe will generate a DAL class to execute the stored procedure. This class won't compile, as it inherits from a base class which isn't provided, but it demonstrates one approach for DAL generation. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Sample Recipes&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;The included recipes demonstrate configuring one or more settings for code generation so that the Wizard can be tailored or avoided altogether. &lt;em&gt;Generate Stored Procedure&lt;/em&gt; shows this best, configuring the metadata provider using the &lt;strong&gt;SourceConfigurationValueProvider&lt;/strong&gt;: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Argument&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SourceConfiguration&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.CodeGeneration.Metadata.SourceConfiguration, Sixeyed.CodeGeneration&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ValueProvider&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SourceConfigurationValueProvider&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;SourceTypeName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Database&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;SourceName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SqlServer Database&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;SourceUri&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Data Source=x\y;Integrated Security=True;Initial Catalog=Scratchpad;&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;ProviderName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Stored Procedure Provider&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ValueProvider&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Argument&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;These settings are the equivalent of the first Wizard page, selecting the metadata source. It specifies the source type and source name, the URI for the source (in this case, the Scratchpad database included with the sample), and the metadata provider name. Having the &lt;em&gt;SourceConfiguration&lt;/em&gt; argument pre-populated means the first Wizard page will be skipped. The recipe also specifies the T4 template to use with the &lt;strong&gt;TemplateConfigurationValueProvider&lt;/strong&gt;: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Argument&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TemplateConfiguration&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.CodeGeneration.Generation.TemplateConfiguration, Sixeyed.CodeGeneration&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ValueProvider&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TemplateConfigurationValueProvider&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;   TemplatePath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;x:\y\z\Templates\Text\StoredProcedure.cs.tt&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ValueProvider&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Argument&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;Only the template path is specified here, but other settings (target namespace, class name etc.) can also be provided. Having the &lt;em&gt;TemplateConfiguration&lt;/em&gt; argument populated means the third Wizard page will not be shown. Running this recipe gives you a Wizard form which only contains the second page, for selecting metadata items, pre-populated with the list which has already been loaded from the configured database: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030809_1747_SixeyedGuid1.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;- note that the other pages are not available, so the user is constrained to using the configured source and T4 template. &lt;/p&gt;
&lt;p&gt;Other recipes demonstrate configuring all or part of the settings needed for code generation. &lt;em&gt;Generate Simple&lt;/em&gt; runs a template which requires no metadata, so it connects to the metadata source, runs the template and adds the project output with no user intervention. &lt;em&gt;Additional Source&lt;/em&gt; demonstrates how you can extend the base code generation guidance package with additional metadata  sources and providers of your own, without rebuilding the base package. Specify the &lt;em&gt;SourceAssemblyConfiguration&lt;/em&gt; argument: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Argument&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SourceAssemblyConfiguration&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.CodeGeneration.Metadata.SourceAssemblyConfiguration, Sixeyed.CodeGeneration&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ValueProvider&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SourceAssemblyConfigurationValueProvider&lt;/span&gt;" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;AssemblyList&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.CodeGeneration.Tests&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ValueProvider&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Argument&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;- and the .NET assemblies named in &lt;em&gt;AssemblyList&lt;/em&gt; (semi-colon separated) will be interrogated at run-time to identify &lt;strong&gt;IMetadataSource&lt;/strong&gt; and &lt;strong&gt;IMetadataProvider&lt;/strong&gt; implementations (there'll be more detail on those interfaces in a coming post). Any available classes will be added to the list of sources and providers shown in &lt;em&gt;Add Generated Items&lt;/em&gt;, and can also be used in &lt;em&gt;SourceConfiguration&lt;/em&gt; argument values. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Usage &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;By providing custom recipes, you can tailor your own Guidance packages which contain recipes for generating classes or other artifacts based on established patterns. This gives the project team an easy way of ensuring consistency for common coding problems in the domain – configuration sections and stored procedure wrappers are simple examples. Note that the URIs and paths are hard-coded. The code generation guidance package will attempt to find a T4 template if the path is not fully stated, but it won't always succeed (there's an issue with returning the running &lt;strong&gt;GuidancePackage&lt;/strong&gt; instance that I haven't tracked down). In a typical project though, templates would be in SCM and source URIs would be consistent among developers, so fully-qualified hard-coded text shouldn't be a problem. &lt;/p&gt;
&lt;p&gt;I'll be extending the sample package to include other templates that may be useful starting points for common code generation tasks – enums to represent reference data, unit tests for .NET and BizTalk artifacts, MSBuild scripts and anything else that occurs. If you have any templates of your own which would fit in a standard library, let me know and I'll add you as a CodePlex contributor. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129921"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129921" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129921.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/08/sixeyed.guidance.codegeneration-sample-package.aspx</guid>
            <pubDate>Sun, 08 Mar 2009 22:46:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129921.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/08/sixeyed.guidance.codegeneration-sample-package.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129921.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Code Generation Guidance Package</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/07/code-generation-guidance-package.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I've been working on a Guidance package which lets you use Visual Studio as a front end to generate items from T4 templates. Using a recipe wizard you choose your metadata from a Web service, database or file system source, and the template is rendered against each of the metadata objects you select. It's on CodePlex here: &lt;a href="http://www.codeplex.com/GAXCodeGeneration"&gt;Code Generation Guidance Package&lt;/a&gt;, and comes in two flavours. The basic Guidance package has a single recipe "Add generated items" – when you run it, you specify a metadata provider, select the items to use for metadata and the T4 template to render against the items.  &lt;/p&gt;
&lt;p&gt;The second package is a sample which extends the functionality of the main Guidance package with custom recipes. This demonstrates how you can define recipes for pre-configured generation types, so the user does not need to complete all the wizard pages – one example specifies a database connection string and a T4 template for generating stored procedure wrappers; to add a new DAL class, the user runs the recipe and just selects which stored procedure(s) they want generated.  &lt;/p&gt;
&lt;p&gt;Neither package comes with any Visual Studio solution or project templates, and they do not need to be used to create the original solution. Any existing project can make use of the code generation features by enabling the package(s) through &lt;em&gt;Tools…Guidance Package Manager&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;In this post I'll give an overview of using the basic &lt;strong&gt;Sixeyed.Guidance.CodeGeneration &lt;/strong&gt;package, and in future posts I'll add some technical detail and give a walkthrough of the sample project. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Add Generated Items &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Run the Add generated items recipe from the Guidance Package Manager, or from the context menu of any project in Solution Explorer. The wizard loads to collect settings - in the first page you select the metadata source type, configure the source and select the metadata provider: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030709_1952_CodeGenerat1.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;During generation, the provider will load each of the selected metadata items and provide them as a property which can be accessed in the T4 template. For instance if you use the SQL Server Stored Procedure provider, your T4 script will have a populated SqlCommand object available to use. &lt;/p&gt;
&lt;p&gt;Provided with the basic Guidance package are the following Sources and Providers: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;
    &lt;div&gt;File System &lt;/div&gt;
    &lt;ul&gt;
        &lt;li&gt;
        &lt;div&gt;File source – for using one or more files as metadata &lt;/div&gt;
        &lt;ul&gt;
            &lt;li&gt;XML File provider – for using XML file contents, exposed to the template as an XmlDocument instance &lt;/li&gt;
            &lt;li&gt;Text File provider – for using text file contents, exposed as a string &lt;/li&gt;
            &lt;li&gt;Assembly File provider – for using a .NET assembly, exposed as an Assembly instance &lt;/li&gt;
        &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
        &lt;div&gt;Directory source – for using a list of directory contents as metadata &lt;/div&gt;
        &lt;ul&gt;
            &lt;li&gt;File List provider – for using a list of file names, exposed as a List&amp;lt;string&amp;gt; instance &lt;/li&gt;
            &lt;li&gt;Directory provider – for using a directory, exposed as a DirectoryInfo instance &lt;/li&gt;
        &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;div&gt;Database &lt;/div&gt;
    &lt;ul&gt;
        &lt;li&gt;
        &lt;div&gt;SQL Server Database &lt;/div&gt;
        &lt;ul&gt;
            &lt;li&gt;Query Result provider – for executing a SQL query and exposing the results in a populated DataSet &lt;/li&gt;
            &lt;li&gt;Table provider – for using a table as metadata, exposed as an empty DataTable with the correct structure &lt;/li&gt;
            &lt;li&gt;Stored Procedure provider – for using stored procedures, exposed as a populated SqlCommand object &lt;/li&gt;
        &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;div&gt;WSDL &lt;/div&gt;
    &lt;ul&gt;
        &lt;li&gt;
        &lt;div&gt;SOAP source &lt;/div&gt;
        &lt;ul&gt;
            &lt;li&gt;Web Method provider – for using a Web service method, exposed as a MethodInfo object &lt;/li&gt;
            &lt;li&gt;Schema provider – for using the WSDL of the service, exposed as an XmlSchema object &lt;/li&gt;
        &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you select a provider, it will load a list of all available metadata items, and you select which items you want to run the T4 template against: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030709_1952_CodeGenerat2.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;The item selection is always a simple list displaying the item name – this will be the name of the file, table, Web method etc (an exception is the QueryResult provider which uses this page to capture the SQL query to be executed). &lt;/p&gt;
&lt;p&gt;In the final screen, select the T4 template to use: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030709_1952_CodeGenerat3.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;The file dialog will default to the "Templates" folder of the Guidance package, but you can navigate to any T4 file. If you want to override the output settings from the T4 file, specifying a different target filename, namespace extension or class name you can do it in the additional properties in this step: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030709_1952_CodeGenerat4.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;Finish the wizard and the recipe will iterate over each of the selected items, populating a representation of the metadata and passing it to the T4 template property.  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;T4 Template Properties &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In order to access metadata item information and create the output, your T4 script needs to specify two properties which will be populated using the Guidance PropertyProcessor engine: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&amp;lt;#@ property processor="PropertyProcessor" name="MetadataItem" #&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&amp;lt;#@ property processor="PropertyProcessor" name="TemplateConfiguration" #&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;The &lt;em&gt;MetadataItem&lt;/em&gt; property is an object implementing &lt;strong&gt;Sixeyed.CodeGeneration.Metadata.Interfaces.IMetadataItem&lt;/strong&gt;: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030709_1952_CodeGenerat5.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;The underlying &lt;em&gt;Item&lt;/em&gt; property gives you access to the populated metadata item – the object type will depend on the provider, and will be specified in the &lt;em&gt;ItemType&lt;/em&gt; property. The &lt;em&gt;Key&lt;/em&gt; for the item (the name shown in the Select Items wizard page) is available, as is the metadata &lt;em&gt;Provider&lt;/em&gt; which can be used to navigate up to the source. &lt;/p&gt;
&lt;p&gt;The &lt;em&gt;TemplateConfiguration&lt;/em&gt; property allows you to control the output of the template, setting default values for the target file name etc. (which can be overridden in the Select Template wizard page). It's an object of type &lt;strong&gt;Sixeyed.CodeGeneration.Generation.TemplateConfiguration&lt;/strong&gt;: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/030709_1952_CodeGenerat6.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Sample Templates &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The CodeGeneration.Sample Guidance package contains a sample template for each of the metadata providers, demonstrating the type of object they expose and how it can be used. The scripts don't do much other than demonstrate usage, but there are fully-fledged scripts for generating wrappers for SQL Server stored procedures, and configuration sections from text files. The full script for the Table provider sample makes straightforward use of the underlying DataTable object: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;template&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; language=&lt;/span&gt;"&lt;span style="color: blue;"&gt;C#&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;property&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; processor=&lt;/span&gt;"&lt;span style="color: blue;"&gt;PropertyProcessor&lt;/span&gt;"&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;MetadataItem&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;property&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; processor=&lt;/span&gt;"&lt;span style="color: blue;"&gt;PropertyProcessor&lt;/span&gt;"&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TemplateConfiguration&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;assembly&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.dll&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;assembly&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Data.dll&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;assembly&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Xml.dll&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;assembly&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.CodeGeneration.dll&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Data&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: brown;"&gt;&lt;strong&gt;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Sixeyed.CodeGeneration.Generation&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt; PrepareOutput(); &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: gray; font-family: Courier New; font-size: 10pt;"&gt;/* &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: gray;"&gt;Table&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;name&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;(from&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;metadata):&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt; MetadataItem.Key &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: gray;"&gt;Table&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;name&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;(from&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;table):&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt; dataTable.TableName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: gray; font-family: Courier New; font-size: 10pt;"&gt;Columns: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt; foreach (DataColumn column in dataTable.Columns) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt;    &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;Column&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name:&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt; column.ColumnName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;Data&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Type:&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt; column.DataType &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: midnightblue; background-color: silver;"&gt;} &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: gray; font-family: Courier New; font-size: 10pt;"&gt;*/ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt; background-color: yellow;"&gt;&amp;lt;#+ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;private DataTable dataTable &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;    get{ return MetadataItem.Item as DataTable; } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;private void PrepareOutput() &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;    TemplateConfiguration.ClassName = string.Format("Table_{0}", MemberName.ToPascalCase(MetadataItem.Key, true)); &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;    TemplateConfiguration.FileExtension = "cs"; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: midnightblue; font-family: Courier New; font-size: 10pt; background-color: silver;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt; background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;(If you don't already have it, the &lt;a href="http://www.visualt4.com/downloads.html"&gt;T4 Editor Community Edition&lt;/a&gt; from Clarius makes editing templates much easier). &lt;/p&gt;
&lt;p&gt;The directives specify the expected properties, and import the relevant reference assemblies and namespaces. The script provides the &lt;em&gt;dataTable&lt;/em&gt; property to easily access the metadata item as a typed DataTable object. In the &lt;em&gt;PrepareOutput&lt;/em&gt; method (called at the start of the template), the script sets up the target class name and file extension. In this case a target filename is not specified, so the engine will use the class name and file extension for the filename. Note there are some helper methods in &lt;strong&gt;Sixeyed.CodeGeneration.Generation.MemberName&lt;/strong&gt; for preparing valid member names. &lt;/p&gt;
&lt;p&gt;Selecting a single table called Manufacturers for this script generates and adds a file called Table_Manufacturers.cs to the selected project, containing the following output: &lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;/* &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Table name (from metadata): Manufacturers &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Table name (from table): Manufacturers &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Columns: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Column Name: ManufacturerId &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;      Data Type: System.Int16 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Column Name: ManufacturerName &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;      Data Type: System.String &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Column Name: AvailableFromDate &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;      Data Type: System.DateTime &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;Column Name: AvailableToDate &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;      Data Type: System.DateTime &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;*/ &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Usage &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;For ad-hoc code generation, this basic Guidance package lets you specify metadata to execute against a T4 template. For commonly used scripts and standard patterns you can build a custom Guidance package which contains your solution structure, and specific recipes for generating known types of item – for DAL classes, entities, configuration sections, proxies or anything else that is based on external metadata. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129906"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129906" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129906.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/07/code-generation-guidance-package.aspx</guid>
            <pubDate>Sun, 08 Mar 2009 01:51:14 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129906.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/07/code-generation-guidance-package.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129906.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Creating Shortcuts in MSBuild</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/10/24/creating-shortcuts-in-msbuild.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Windows shortcuts are .LNK files – a proprietary binary format which is not simple to generate. If you want to create shortcuts as part of an MSBuild deployment, the main issue is that the paths are not relative, they need to be explicit, so you can't create your own shortcuts and copy them. Alternatives are to create .URL or batch files containing relative paths, but they don't have the niceties of shortcuts. &lt;/p&gt;
&lt;p&gt;You can generate .LNK shortcuts in MSBuild by shelling out to some VBScript at runtime, when you've deployed your files and know the exact paths. It's not a pretty solution, but it's fast and reliable. Create a .VBS file with the following content to generate a shortcut from given parameters: &lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;'CreateShortcut.vbs &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;'Generates a .LNK shortcut to the specified program &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;'Usage: CreateShortcut.vbs &amp;lt;pathToExe&amp;gt; &amp;lt;exeName&amp;gt; &amp;lt;shortcutName&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; args, arg &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Set&lt;/span&gt; args = WScript.Arguments &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; workingDirectory, exeName, shortcutName &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;workingDirectory=args(&lt;span style="color: red;"&gt;0&lt;/span&gt;) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;exeName=args(&lt;span style="color: red;"&gt;1&lt;/span&gt;) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;shortcutName=args(&lt;span style="color: red;"&gt;2&lt;/span&gt;) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; WshShell &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Set&lt;/span&gt; WshShell = WScript.CreateObject(&lt;span style="color: rgb(163, 21, 21);"&gt;"WScript.Shell"&lt;/span&gt;) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; objLink &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;Set&lt;/span&gt; objLink = WshShell.CreateShortcut(&lt;span style="color: rgb(163, 21, 21);"&gt;"Shortcuts\"&lt;/span&gt; &amp;amp; shortcutName &amp;amp; &lt;span style="color: rgb(163, 21, 21);"&gt;".lnk"&lt;/span&gt;) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;objLink.Description = shortcutName &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;objLink.TargetPath = workingDirectory &amp;amp; &lt;span style="color: rgb(163, 21, 21);"&gt;"\"&lt;/span&gt; &amp;amp; exeName &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;objLink.WindowStyle = &lt;span style="color: red;"&gt;1 &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;objLink.WorkingDirectory = workingDirectory &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;objLink.Save&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;Then call it from MSBuild after you've deployed the target file and know the path: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Exec&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Command&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;'&lt;span style="color: blue;"&gt;CreateShortcut.vbs """$(AppDir)""" AppName.exe AppFriendlyName.exe&lt;/span&gt;'&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;Points to note: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;If you have any spaces in the arguments (C:\Program Files\etc) you need to wrap them in triple double-quotes ("""C:\Program Files\etc"""), otherwise each word is parsed as a separate argument in VBScript; &lt;/li&gt;
    &lt;li&gt;The friendly name of the shortcut can end in any extension – Windows hides the final .LNK , so if you specify a .EXE it will display as an EXE; &lt;/li&gt;
    &lt;li&gt;Shortcuts aren't limited to executables, if you pass a Word file as the &lt;em&gt;exeName&lt;/em&gt; argument and end the &lt;em&gt;shortcutName&lt;/em&gt; with .DOC, it'll launch the document in Word and show it with the Word icon in Explorer; &lt;/li&gt;
    &lt;li&gt;You have a lot of control over the link from the &lt;em&gt;CreateShortcut&lt;/em&gt; call – including the startup window type, arguments and the icon. The example above is a straightforward one which just sets the minimum necessary. &lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126089"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126089" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/126089.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/10/24/creating-shortcuts-in-msbuild.aspx</guid>
            <pubDate>Sat, 25 Oct 2008 00:13:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/126089.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/10/24/creating-shortcuts-in-msbuild.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/126089.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Quick registration of Package in progress… This may take a while</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/10/15/quick-registration-of-package-in-progress-this-may-take-a.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The Guidance Automation Extensions Toolkit (see &lt;a href="http://msdn.microsoft.com/en-us/vsts2008/aa718949.aspx"&gt;GAX Toolkit&lt;/a&gt;) gives you this lovely message when you use the "Quick Register" action in your GAX package development. It's true that it can take a while, although it's substantially quicker than the full registration action.  &lt;/p&gt;
&lt;p&gt;When you're in development though, solutions using your GAX package will read the contents from the project's &lt;strong&gt;bin\Debug&lt;/strong&gt;, so you may not need to re-register between builds at all. Experiments with registration types suggest that they need to be used in the following situations: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Full Register&lt;/strong&gt; – needed the first time you register the package, and may be needed following an Unregister if the package has been corrupted or isn't functioning as expected. Takes several minutes and does a variety of interesting things (check Task Manager while it's running); builds the solution and validates package XML before deploying. &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Quick Register&lt;/strong&gt; – may take a while, but usually in the order of tens of seconds rather than minutes. Also builds the solution and validates the package XML, but doesn't do the full suite of registration tasks. Not necessary in normal use, although if you've modified the XML it's worth having it validated before trying to use it. &lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;No registration&lt;/strong&gt; – in dev, the package is read from &lt;strong&gt;bin\Debug&lt;/strong&gt;, so if you're adding or modifying templates, you can just rebuild and they'll be immediately available. Similarly if you change or add to the code in the project or dependencies, close any solutions using the GAX package and rebuild and the changes will take effect when you re-open. Interestingly, if you modify the XML – e.g. to add a new action – you can also just rebuild and not register, and the new action will be listed when you open a solution using the package. If not, disable then re-enable the package, and the new action should appear. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Obviously this only applies in dev, and if you deploy your GAX package using the MSI, you'll need to redeploy in full for changes to take effect. Useful to know though, and may mean your GAX development takes less of a while.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125850"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125850" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/125850.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/10/15/quick-registration-of-package-in-progress-this-may-take-a.aspx</guid>
            <pubDate>Wed, 15 Oct 2008 05:33:47 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/125850.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/10/15/quick-registration-of-package-in-progress-this-may-take-a.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/125850.aspx</wfw:commentRss>
        </item>
        <item>
            <title>ExecuteT4Template MSBuild task: Updated</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/10/04/executet4template-msbuild-task-updated.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As Cory pointed out, my original task to execute T4 templates under MSBuild (replacing property markers in the T4 script with evaluated values from the build, see: &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx"&gt;An MSBuild task to execute T4 templates&lt;/a&gt;), fails under MSBuild 3.5. This is down to a change in the object model in the framework. All the useful classes are internal and all the useful properties are private, so they have to be reflected over - which makes my code brittle. &lt;/p&gt;
&lt;p&gt;I've updated the task as part of a set here: &lt;a href="http://www.sixeyed.plus.com/fileDrop/code/MSBuild/Sixeyed.MSBuild.zip"&gt;Sixeyed MSBuild tasks&lt;/a&gt;, and it now works with either MSBuild 2.0 or 3.5. &lt;/p&gt;
&lt;p&gt;Another update will be coming soon, to allow you to use named item group values, as well as property values and whole item groups in the script. A script can be marked with &lt;span style="font-family: Courier New;"&gt;%(Collection.Identity)&lt;/span&gt; and when the task is called iteratively over a collection, the script will be populated with the current collection value each time. I'm also planning to change it to use the T4 engine directly rather than invoking the TextTransform console app, to hopefully speed up the execution time. &lt;/p&gt;
&lt;p&gt;I'm using this task increasingly in builds now. It's a lot neater than having multiple XML or Regex file updates, and the template can be used to isolate logic so the builds stay clean. Currently it's used to dynamically generate Wix scripts, generate BizTalk bindings file for a set of environments, generate documentation projects for &lt;a href="http://codeplex.com/shfb"&gt;Sandcastle Help File Builder&lt;/a&gt; and produce config files for running DevPartner code coverage. Some of those templates may be generically useful, so I'll add them to MSDN when I get to the next update.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125632"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125632" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/125632.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/10/04/executet4template-msbuild-task-updated.aspx</guid>
            <pubDate>Sat, 04 Oct 2008 14:14:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/125632.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/10/04/executet4template-msbuild-task-updated.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/125632.aspx</wfw:commentRss>
        </item>
        <item>
            <title>An MSBuild task to execute T4 templates</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I was looking for an MSBuild task which could execute a T4 template, replacing tags in the template with the value of properties or item groups from the build - giving your T4 templates access to all the runtime values used in the build scripts. So you start with a T4 template like this: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;template&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; language=&lt;/span&gt;"&lt;span style="color: blue;"&gt;C#&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; extension=&lt;/span&gt;"&lt;span style="color: blue;"&gt;.txt&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#@&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;&lt;strong&gt;assembly&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; name=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.dll&lt;/span&gt;"&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: gray; font-family: Courier New; font-size: 10pt;"&gt;***START &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Property&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;value:&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;StartDir=&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;$(StartDir)&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Item&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Group&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;value:&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;TextFiles&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;=&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;@(TextFiles) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: gray; font-family: Courier New; font-size: 10pt;"&gt;***END &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;- execute it through a call to &lt;strong&gt;ExecuteT4Template&lt;/strong&gt; in your build target: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;StartDir&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;C:&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;StartDir&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemGroup&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextFiles&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Include&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(BuildOutputDir)\*.txt&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemGroup&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Target&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ExecuteTemplate&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ExecuteT4Template&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;TemplatePath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;T4Sample.tt&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;OutputPath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;c:\T4SampleOutput.txt&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Target&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;- and it produces the following output: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;***START &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; Property value: StartDir= C:   &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt; Item Group value: TextFiles = \zeros.txt &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;***END &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;There wasn't one that I could find so I put a simple one together. A couple of fiddly things worth noting if you do something similar: &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;the project's property values are not exposed to the executing task in an accessible way, so you have to reflect around BuildEngine to get hold of the executing project;  &lt;/li&gt;
    &lt;li&gt;if you don't want to write an ITextTemplatingEngineHost or rely on a GAX or other host, you'll end up shelling out to TextTransform.exe (as I have). &lt;br /&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Full source for the task is here: &lt;a href="http://www.sixeyed.com/fileDrop/code/MSBuild/Sixeyed.MSBuild/Sixeyed.MSBuild/Tasks/CodeGen/ExecuteT4Template.cs"&gt;ExecuteT4Template.cs&lt;/a&gt; (note this uses version 1.1 of the TextTransform tool). &lt;/p&gt;
&lt;p&gt;A couple of things to note:  this task will update all instances of property and item tags in the template - &lt;strong&gt;$(propertyName)&lt;/strong&gt; or &lt;strong&gt;@(itemGroupName)&lt;/strong&gt; (it's not clever enough to deal with &lt;strong&gt;%(itemGroupName.ValueName)&lt;/strong&gt;)- with the value from MSBuild, if the named property/item group exists in the project. Potentially you may want to leave certain tags in place in the template, in which case you'll need to ensure there are no matching properties in the build, or extend the task to take a list of names to ignore.  &lt;/p&gt;
&lt;p&gt;Also, if you're using a value in your script which is the output from another task, then the task which produces the output must be in a separate target which completes before the call to ExecuteT4Template. MSBuild seems only to store properties/item groups from task outputs when targets are completed, so if the output is created in the same target as the T4 task, the property won't be registered and the tag in the template won't be replaced. &lt;/p&gt;
&lt;p&gt;I have a couple of other tasks which all relate to deploying BizTalk and ESB Service Providers, so I'll add them to the &lt;a href="http://www.codeplex.com/ESBSimpleSamples"&gt;ESBSimpleSamples CodePlex project&lt;/a&gt; along with this one.  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124015"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124015" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/124015.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx</guid>
            <pubDate>Fri, 25 Jul 2008 18:54:23 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/124015.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx#feedback</comments>
            <slash:comments>18</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/124015.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Scripting Branch Creation in Perforce</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/04/04/scripting-branch-creation-in-perforce.aspx</link>
            <description>&lt;br /&gt;
To simplify the branching process, allow automation and remove the errors likely from manually branching, I'd like the whole process to be scripted. The P4 command allows us to do this, but there are complications as it requires user input via the specification forms for most of its commands. You can direct it to read the input from a file, but that's not much help when you want to use variables to specify branch names etc.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;Generating Specification Forms on the Fly&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
My solution was to create a simple console app to generate spefication forms based on input parameters. The variables in the script go into the generator which stores them as files, which P4 can use as input. It's not terribly elegant, but it's efficient and I haven't found any other solutions out there. The code is on CodePlex here: &lt;a href="http://www.codeplex.com/GenerateP4SpecForm"&gt;Generate Perforce Specification Form&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Using the console app, it's easy to take the manual steps from &lt;a href="../../../../EltonStoneman/archive/2008/04/04/branching-with-perforce.aspx"&gt;Branching with Perforce&lt;/a&gt; and script them for automation. In this case, I'm expecting branching to be an occassional job so the purpose of scripting it is to reduce the possibility of error and simplify the branching process for anyone who needs to do it and doesn't want to trawl through these blogs.&lt;br /&gt;
&lt;br /&gt;
With this in mind, the script is a Windows batch file (the full script is &lt;span style="font-weight: bold;"&gt;BranchWorkspace.bat&lt;/span&gt; in the Samples directory of the CodePlex source) rather than a build task. It should be straightforward to read, but I'll dissect it here to show how the commands fit in with the manual process.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;Walkthrough&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;Firstly the batch file sets up parameters for all the variables we'll use - branch name, branch master workspace name, views etc. Then it follows the same order as the manual process, generating the specification forms where needed, then invoking the P4 command and telling it to read from the spec form.&lt;br /&gt;
&lt;br /&gt;
1. Create the branch view&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;::generate spec form for the branch:&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;set branchSpecPath=C:\%branchName%.p4&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;GenerateP4SpecForm "WRITE" "%branchSpecPath%" "|" "Branch: %branchName%|Owner:    elton.stoneman|Description: Created by elton.stoneman.|Options:    unlocked|View: %mainView% %branchView%"&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;The console app takes parameters telling it where to create the spec form, how the form options are separated (I use a pipe as there are colons in the options), and then the pipe-separated option list.  &lt;br /&gt;
&lt;br /&gt;
What goes into the list depends on the type of spec form P4 wants; there are samples in the CodePlex source, or you can copy and paste from a real spec form, or many of the commands take a -o parameter so you can output an existing spec form and use that as the basis.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;::create the branch view:&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;p4 branch -i &amp;lt;%branchSpecPath%&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;&lt;/span&gt;- the branch view is created and we pass the spec form path to P4 so there's no user intervention.&lt;br /&gt;
&lt;br /&gt;
2. Create the master workspace&lt;br /&gt;
&lt;br /&gt;
As before, generate the relevant spec form and pass it into P4:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;::generate spec form for the branch master workspace:&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;set branchClientSpecPath=C:\%branchClient%.p4&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;GenerateP4SpecForm "WRITE" "%branchClientSpecPath%" "|" "Client: %branchClient%|Owner: elton.stoneman|Host: myHost|Description: Created by elton.stoneman.|Root: %branchClientRoot%|Options: noallwrite noclobber nocompress unlocked nomodtime normdir|SubmitOptions: submitunchanged|LineEnd: local|View: %branchView% %branchClientView%"&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;::create branch workspace:&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;p4 client -i &amp;lt;%branchClientSpecPath%&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. Flag files to be branched&lt;br /&gt;
&lt;br /&gt;
No spec form needed here, but the batch file allows you to branch from the current revisions or from a specified label:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;::integrate the branch back to main - branch to label if provided:&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;IF "%label%"==" " p4 -c%branchClient% integrate -b %branchName%&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;IF NOT "%label%"==" " p4 -c%branchClient% integrate -b %branchName% @%label%&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4. Submit the change list&lt;br /&gt;
&lt;br /&gt;
This is a bit different as the submit command launches a spec form listing the files to be submitted, and requires you to add a description. We can't generate the spec form here, as we'll lose the file list, so instead we output the file list first:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;::get a list of the changes (required for Submit):&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;set changePath=c:\%branchClient%.chg&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;p4 -c%branchClient% change -o &amp;gt;%changePath%&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
- and then use the UPDATE mode of the console app to set the description (P4 always uses the same text for the default description):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;IF "%label%"==" " GenerateP4SpecForm "UPDATE" "%changePath%" "&amp;lt;enter description here&amp;gt;" "MASTER created from branch: %branchName%"&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;IF NOT "%label%"==" " GenerateP4SpecForm "UPDATE" "%changePath%" "&amp;lt;enter description here&amp;gt;" "MASTER created from branch: %branchName%, label: %label%"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This way we get the full change list from Perforce and add in our description (in this case, specifying the branch view and label used to get the files). Now we submit using the updated change list:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;::submit to create branch in depot:&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;p4 -c%branchClient% submit -i &amp;lt;%changePath%&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
And the branch is complete and populated.&lt;br /&gt;
&lt;br /&gt;
Note, the sample batch file leaves the generated spec forms in place, in case of any issues. It's a simple change to make the script delete them at the end.&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121042"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121042" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/121042.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/04/04/scripting-branch-creation-in-perforce.aspx</guid>
            <pubDate>Fri, 04 Apr 2008 16:17:40 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/121042.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/04/04/scripting-branch-creation-in-perforce.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/121042.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>