<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>CodeGen</title>
        <link>http://geekswithblogs.net/EltonStoneman/category/8204.aspx</link>
        <description>CodeGen</description>
        <language>en-GB</language>
        <copyright>EltonStoneman</copyright>
        <managingEditor>elton.stoneman@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Visualizing SOA’s Return on Investment</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/26/visualizing-soas-return-on-investment.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;This is the rather grand title of a WebCast I've recorded recently which tries to illustrate where the return on investment comes after moving to a SOA strategy. The video is on Digital Forum:  &lt;a href="http://www.digitalforumtv.com/#/Community/852"&gt;Visualizing SOA ROI&lt;/a&gt; , and the Open Source proof of concept it references is on CodePlex: &lt;a href="http://www.codeplex.com/ESBSimpleSamples"&gt;ESBSimpleSamples&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;In the WebCast I start with a blank Visual Studio solution and create a new Web app which consumes an existing service. All in it takes 3 lines of code and around 3 minutes of development (most of it spent correcting typos), and it doesn't require me to have any understanding of the underlying SOA infrastructure – in this case, Microsoft's ESB Guidance package sitting on BizTalk Server 2006 R2. Equally important, assuming the service we consume is in production, the testing and deployment effort needed for the new project is minimal. &lt;/p&gt;
&lt;p&gt;This is a rework of a presentation I did with a client where I wanted to show how quick and easy it is to use their SOA implementation. I had reservations of showing a code demonstration to an audience which included IT heads (IT Director and Solution Architects) and project management, but it was surprisingly well received, so I've reproduced it using services and components which are publicly available. &lt;/p&gt;
&lt;p&gt;Direct links to the references in the WebCast are here: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;ESB Guidance: &lt;a href="http://www.codeplex.com/esb"&gt;http://www.codeplex.com/esb&lt;/a&gt; 		&lt;/li&gt;
    &lt;li&gt;UK SOA/BPM User Group presentation: &lt;a href="http://sbug.org.uk/media/p/129.aspx"&gt;http://sbug.org.uk/media/p/129.aspx&lt;/a&gt; 		&lt;/li&gt;
    &lt;li&gt;Blog posts on ESB Guidance: &lt;a href="http://geekswithblogs.net/EltonStoneman/category/7947.aspx"&gt;http://geekswithblogs.net/EltonStoneman/category/7947.aspx&lt;/a&gt; 		&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130437"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130437" 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/130437.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/26/visualizing-soas-return-on-investment.aspx</guid>
            <pubDate>Thu, 26 Mar 2009 18:36:18 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/130437.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/26/visualizing-soas-return-on-investment.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/130437.aspx</wfw:commentRss>
        </item>
        <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>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>T4 template to generate Wix scripts to generate WCF MSIs in MSBuild</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/09/04/t4-template-to-generate-wix-scripts-to-generate-wcf-msis.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;Snappy title. We have a project which contains lots of WCF Service projects, and we want to generate MSIs so we can deploy them to IIS. The gaps between the projects are minimal as they all use the same structure, so instead of having separate Setup or Wix files in each of the solutions, generating the WXS files on the fly was an option. &lt;/p&gt;
&lt;p&gt;The installer steps we wanted were reasonably simple: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;install WCF artifacts to the chosen directory (.svc and web.config files) &lt;/li&gt;
    &lt;li&gt;install WCF binaries to &lt;em&gt;the chosen directory\bin &lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;install dependencies to the GAC&lt;em&gt; 			&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;create a virtual directory in IIS pointing to the install directory&lt;em&gt; 			&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only UI we particularly needed was the choice of install directory, so the Wix for this fits into a fairly straightforward T4 template: &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;.xml&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="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;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.IO&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;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Security.Cryptography&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;import&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red;"&gt; namespace=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Text&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="color: gray;"&gt;&amp;lt;?xml&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;version="1.0"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;encoding="UTF-8"?&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;&amp;lt;Wix&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;xmlns="http://schemas.microsoft.com/wix/2006/wi"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"&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;&amp;lt;Product&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetProductId() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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;Name="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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;Language="1033" &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;Version="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; VersionNumber &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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;Manufacturer="Company" &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;UpgradeCode="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetUpgradeCode() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;Package&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;InstallerVersion="200"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Compressed="yes"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Media&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="1"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Cabinet="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;.Install.cab"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;EmbedCab="yes"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="TARGETDIR"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="SourceDir"&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;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="ProgramFilesFolder"&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;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="CompanyFolder"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="Company"&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;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="INSTALLLOCATION"&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="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="Website"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; foreach (string filePath in this.WcfArtifacts.Split(';')) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;            { &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;                this.AddFile(filePath);     &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: navy; background-color: white;"&gt;            }&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&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;&amp;lt;/Component&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; int index = 0; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;            foreach (string assemblyPath in this.WcfDependencies.Split(';')) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: navy; background-color: white;"&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="color: red;"&gt;                &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="GACComponent_&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; index++ &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;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;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;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;SharedDllRefCount="yes"&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.AddAssemblyToGAC(assemblyPath); &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;&amp;lt;/Component&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&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="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Directory&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WebsiteBin"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Name="bin"&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;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WebsiteBin"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.AddAssembly(this.WcfAssembly); &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;&amp;lt;/Component&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;&amp;lt;/Directory&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;&amp;lt;/Directory&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;&amp;lt;/Directory&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;&amp;lt;/Directory&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Component&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="VirtualDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Guid="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; this.GetNewGuid() &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;gt;&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;iis:WebVirtualDir&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WcfVirtualDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Alias="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName.TrimEnd(".Wcf".ToCharArray()) &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;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;Directory="INSTALLLOCATION"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;WebSite="DefaultWebSite"&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;&amp;lt;iis:WebApplication&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WcfApplication"&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="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;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;/&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;&amp;lt;/iis:WebVirtualDir&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;&amp;lt;/Component&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;&amp;lt;/Directory&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;iis:WebSite&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="DefaultWebSite"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Description="Default&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Web&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Site"&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;&amp;lt;iis:WebAddress&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="AllUnassigned"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Port="80"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;/iis:WebSite&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Feature&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="ProductFeature"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Title="&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; ServiceName &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;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;Level="1"&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;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="Website"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WebsiteBin"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; int i = 0; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;            foreach (string assemblyPath in this.WcfDependencies.Split(';')) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: navy; background-color: white;"&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="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="GACComponent_&lt;/span&gt;&lt;span style="background-color: yellow;"&gt;&amp;lt;#=&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&gt; i++ &lt;/span&gt;&lt;span style="background-color: yellow;"&gt;#&amp;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;/&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="background-color: yellow;"&gt;&amp;lt;#&lt;/span&gt;&lt;span style="color: navy; background-color: white;"&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="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;ComponentRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="VirtualDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;/Feature&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;Property&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WIXUI_INSTALLDIR"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Value="INSTALLLOCATION"/&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;&amp;lt;UIRef&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WixUI_InstallDir"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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;&amp;lt;WixVariable&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Id="WixUIDialogBmp"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;Value="$(WixPath)\SetupBackground.bmp"&lt;/span&gt;&lt;span style="color: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&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: red;"&gt; 			&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/Product&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;&amp;lt;/Wix&amp;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: navy; background-color: white;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string ServiceName &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return "$(ProjectName).$(ProjectFilter)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string VersionNumber &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return "$(Version)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string WcfArtifacts &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return @"@(WcfArtifacts)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string WcfAssembly &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;{ get{ return @"@(WcfAssembly)"; }} &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt; background-color: white;"&gt;private string WcfDependencies &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="background-color: white;"&gt;{ get{ return @"@(WcfDependencies)"; }}&lt;/span&gt; 		&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: navy; font-family: Courier New; font-size: 10pt;"&gt;…&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;- the full template is here: &lt;a href="http://www.sixeyed.plus.com/fileDrop/code/T4Templates/Services.Wcf.wxs.tt"&gt;WCF Service Wix template&lt;/a&gt;.  &lt;/p&gt;
&lt;p&gt;A couple of interesting things here – the Guids are generated from the name of the elements (see &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/06/26/generating-deterministic-guids.aspx"&gt;Generating Deterministic Guids&lt;/a&gt;), so multiple versions will have the same Guid and will operate as updates, provided the name of the service doesn't change;  the tags for MSBuild properties in the template get resolved using the &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx"&gt;ExecuteT4Template MSBuild task&lt;/a&gt;; the GACd assemblies flag themselves as &lt;em&gt;SharedDllRefCount&lt;/em&gt; so if you uninstall this package, the files will be left in the GAC if any other packages use them, but removed if this is the only package that uses them. &lt;/p&gt;
&lt;p&gt;Another custom task is needed to resolve the dependencies of the WCF assembly (sample version here: &lt;a href="http://www.sixeyed.plus.com/fileDrop/code/MSBuild/Sixeyed.MSBuild.zip"&gt;MSBuild ResolveDependencies task&lt;/a&gt;), and the MSBuild snippet to run it together with the Wix commands looks like this: &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;ResolveWcfDependencies&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: green;"&gt; List the dependencies for the Wcf service:&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;ResolveDependencies&lt;/span&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;@(WcfAssembly)&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;Filter&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(CompanyName).$(ProductName)&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;Output&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;TaskParameter&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;DependencyList&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;ItemName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;WcfDependencies&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;ResolveDependencies&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;&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;PublishWcf&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;DependsOnTargets&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt; ResolveWcfDependencies&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Condition&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;'@(WcfAssembly)' != ''&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: green;"&gt; Create the wxs file: &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;Message&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Determined Wcf dependencies: @(WcfDependencies)&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;ToolPath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(MSBuildProjectDirectory)\$(BuildBinDir)&lt;/span&gt;"&lt;span style="color: blue;"&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; 			&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;$(TemplateRoot)\Services.Wcf.wxs.tt&lt;/span&gt;"&lt;span style="color: blue;"&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;OutputPath&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wxs&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;Output&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;TaskParameter&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TempFilePath&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;ItemName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;T4TempFilePath&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;&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;Message&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;T4 template resolved to: @(T4TempFilePath)&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: green;"&gt; Produce intermediate Wix obj:&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;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;"$(WixPath)\candle" -out "$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wixobj" "$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wxs" -ext WixIIsExtension -ext WixUiExtension&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: green;"&gt; Produce MSI:&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;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;"$(WixPath)\light" -out "$(PublishServiceDir)\$(ProductName).$(ProjectName).Wcf.msi" "$(ArtefactWixDir)\$(ProductName).$(ProjectName).Wcf.wixobj" -ext WixIIsExtension -ext WixUiExtension -cultures:en-us&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;- we store all the intermediate files (the T4 template with resolved property values, WXS and WIXOBJ files) to help with debugging. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124932"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124932" 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/124932.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/09/04/t4-template-to-generate-wix-scripts-to-generate-wcf-msis.aspx</guid>
            <pubDate>Thu, 04 Sep 2008 19:55:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/124932.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/09/04/t4-template-to-generate-wix-scripts-to-generate-wcf-msis.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/124932.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Flattening WSDL from WCF Services</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/07/30/flattening-wsdl-from-wcf-services.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;If you're hosting WCF services in IIS and try accessing the WSDL using &lt;strong&gt;ServiceDescriptionImporter.Import&lt;/strong&gt;,  you'll get an error saying &lt;em&gt;Unable to import binding BasicHttpBinding_IXyzService… &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;WCF separates out its schemas into logical components, which ServiceDescriptionImporter and other clients (including the &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/06/05/contract-first-codegen.aspx"&gt;ESBSimpleSamples ServiceClient generator&lt;/a&gt;) can't work with, as they're expecting a single flat WSDL. &lt;/p&gt;
&lt;p&gt;Christian Weyer from Thinktecture has a solution here: &lt;a href="http://blogs.thinktecture.com/cweyer/archive/2007/05/10/414840.aspx"&gt;Improving WCF Interoperability: Flattening your WSDL&lt;/a&gt;. If you download and build his sample project, copy &lt;strong&gt;Thinktecture.ServiceModel.Extensions.Description.dll&lt;/strong&gt; to your service bin folder and amend your .svc description to use the Thinktecture factory: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;% @ServiceHost Language=C# Service="Xyz.XyzService" Factory="Thinktecture.ServiceModel.Extensions.Description.FlatWsdlServiceHostFactory " %&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;- this will return a flattened WSDL, so tools expecting one file will work correctly.  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124116"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124116" 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/124116.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/07/30/flattening-wsdl-from-wcf-services.aspx</guid>
            <pubDate>Wed, 30 Jul 2008 17:23:15 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/124116.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/07/30/flattening-wsdl-from-wcf-services.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/124116.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>SSO Config Tool</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/06/29/sso-config-tool.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 Enterprise Single Sign On database can function as a centralized configuration store, as well as an identity store, which is available to all BizTalk instances in a group, and also to custom .Net apps. For a clear explanation of the benefits and drawbacks of the EntSSO approach (and the alternative options), see Michael Stephenson's post &lt;a href="http://geekswithblogs.net/michaelstephenson/archive/2008/05/25/122381.aspx"&gt;Where do I store my custom configuration for a BizTalk solution&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Here I'll look at overcoming some of the practical issues in developing, deploying and maintaining config in an EntSSO store using  another tool I've been using for a while and have recently put onto CodePlex: &lt;a href="http://www.codeplex.com/SSOConfigTool"&gt;SSO Config Tool&lt;/a&gt;.  &lt;/p&gt;
&lt;p&gt;The original purpose was to codegen a strongly-typed configuration model that abstracted away the EntSSO store, and made read-only config values available from a static class for expressions: &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/062908_1841_SSOConfigTo1.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;- or .Net code: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;//extract the UDDI config settings: &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt; uddiUrl = &lt;span style="color: teal;"&gt;ConsolidatedGyroscope_App1Config&lt;/span&gt;.UDDIServerUrl; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;uint&lt;/span&gt; uddiTimeout = &lt;span style="color: teal;"&gt;ConsolidatedGyroscope_App1Config&lt;/span&gt;.UDDICacheTimeout; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So it does that (if you're looking for an app which just lets you manage SSO stores, have a look at &lt;a href="http://seroter.wordpress.com/2007/09/21/biztalk-sso-configuration-data-storage-tool/"&gt;Richard Seroter's Config Application Manager&lt;/a&gt;), and it also gives you: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;a console app to generate the config, and to import/export between EntSSO and an XML config file &lt;/li&gt;
    &lt;li&gt;MSBuild task versions of the console functionality  &lt;/li&gt;
    &lt;li&gt; a UI version of the console functionality, which also lets you maintain config settings: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/062908_1841_SSOConfigTo2.png" /&gt; 	&lt;/p&gt;
&lt;p&gt;There are a couple of things worth noting here.  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Application Settings &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;These are all mandatory. The Groups specify who has access to read and update the config store settings. Groups must exist at the time you try and save the app to EntSSO, and they cannot be built-in groups or the "Everyone" group (not that you would…). The BizTalk groups are sensible options, so they're the default for the UI. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Fields&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;Field types are limited (by EntSSO) to one of the following built-in types: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;String &lt;/li&gt;
    &lt;li&gt;Int32 &lt;/li&gt;
    &lt;li&gt;UInt32 &lt;/li&gt;
    &lt;li&gt;Boolean &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The type you select will be emitted as the type of the property in the generated config model. Values are validated against the given type. The Masked option is a little misleading – all entries in EntSSO are encrypted, but if the field is defined as Masked in the config store then you can only retrieve it if you access EntSSO with a specific flag. The generated config model gives itself this permission, so the Masked value has no effect if you only use the config model. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;XML &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A custom schema is used so I can capture the expected field data type (rather than inferring it) – so it's similar but not compatible with the structure used by &lt;strong&gt;ssomanage&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Generated Code&lt;/em&gt; 	&lt;/p&gt;
&lt;p&gt;The config model produced by SSOConfigTool uses a couple of helper classes in the SSOConfig namespace. When you generate the model, you can either generate the source code (so you'll have to add the SSOConfig assembly to your app as well as adding the C# class), or a compiled assembly (which contains the configuration model in your selected namespace, and the helper classes in SSOConfig, so you can use it on its own). The API (Microsoft.BizTalk.Interop.SSOClient) should be in the GAC. &lt;/p&gt;
&lt;p&gt;Structure is quite basic – there's an &lt;strong&gt;SSOApplication&lt;/strong&gt; class that represents the config store for an application, and the business of wrapping the EntSSO API is done in &lt;strong&gt;SSOHelper&lt;/strong&gt;. The config class uses &lt;strong&gt;SSOApplication&lt;/strong&gt; behind the scenes to get field values,  and exposes them as the correct type. The class also exposes a CacheSSOAccess property which determines whether values are fetched from EntSSO on each call, or lazy loaded – it defaults to being lazy loaded (this is a static class so be aware of the thread implications if you're changing this value). &lt;/p&gt;
&lt;p&gt;Some quirks with the EntSSO API are documented here: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://blogs.msdn.com/kevin_michael_schultz/archive/2006/12/14/eat-my-rough-draft-punk.aspx"&gt;http://blogs.msdn.com/kevin_michael_schultz/archive/2006/12/14/eat-my-rough-draft-punk.aspx&lt;/a&gt; 		&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://suneetnangia.spaces.live.com/Blog/cns!AF14D545C10A3693!300.entry"&gt;http://suneetnangia.spaces.live.com/Blog/cns!AF14D545C10A3693!300.entry&lt;/a&gt; 		&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the config tool, the implication is that it creates a dummy field in the config app, but you won't see it unless you look in SSODB. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Usage &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I've mainly used the UI to create the app in the EntSSO store, then used the MSBuild tasks to extract the app as XML and generate code from it. Alternatively you can use the build tasks to create the SSO store and/or generate code from a saved config file. The sample MSBuild files in the project show these uses. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Work Outstanding &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Only a couple of things – firstly the SSO Config Tool (in its various guises) expects the EntSSO store to be available locally, so currently it doesn't allow you to run it from one machine to update SSO on another. The other one is more of an annoying niggle – if you try to open an SSO app from the UI, you'll probably find the dropdown list of available apps empty. This is down to &lt;strong&gt;ISSOMapper.GetApplications&lt;/strong&gt; always returning an empty list, so until I work out why it thinks the user isn't entitled to view them, you'll need to type in the name of the app. Think of it as a security measure. &lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123462"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123462" 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/123462.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/06/29/sso-config-tool.aspx</guid>
            <pubDate>Mon, 30 Jun 2008 00:41:30 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/123462.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/06/29/sso-config-tool.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/123462.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Contract-First CodeGen</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/06/05/contract-first-codegen.aspx</link>
            <description>&lt;p&gt;I've added some codegen scripts to the &lt;a href="http://www.codeplex.com/ESBSimpleSamples"&gt;ESBSimpleSamples&lt;/a&gt; project, and a simple UI which runs the scripts against metadata it retrieves from a WSDL endpoint. The codegen templates were built for a custom tool which we use (not public I'm afraid), and then stripped down for the "ServiceClient.Generator" tool, so the structure might look a bit odd, but they do the following jobs: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Extract the schema from the WSDL location to XSD (ready for loading into BizTalk) &lt;/li&gt;
    &lt;li&gt;Build a (very) clean request DTO for the selected method &lt;/li&gt;
    &lt;li&gt;Build a (similarly) clean response DTO for the selected method &lt;/li&gt;
    &lt;li&gt;Build a typed ServiceRequest object for use with the ESBSimplseSamples.ServiceClient library, giving access to the service via ESB &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The classes are just displayed in the form at the moment (using &lt;a href="http://www.codeplex.com/ScintillaNET"&gt;ScintillaNET&lt;/a&gt; for readability): &lt;/p&gt;
&lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/060508_2045_ContractFir1.png" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;(if anyone has a burning desire to increase the functionality of the UI, let me know and I'll add you to the CodePlex project). &lt;/p&gt;
&lt;p&gt;I'm intending to add further codegen scripts to generate: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;a unit test stub for calling the ServiceRequest  &lt;/li&gt;
    &lt;li&gt;a sample XML message containing the necessary itinerary steps in the header, and some dummy values in the body &lt;/li&gt;
    &lt;li&gt;settings for adding the service to a UDDI repository. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This all works splendidly for the straightforward services I've tried so far, though I'm expecting some rework to deal with services that use types across a variety of schemas. &lt;/p&gt;
&lt;p&gt;Rummaging around in the System.Web.Services.Description namespace to get the WSDL metadata really isn't much fun. I'll write a post moaning about it in more detail later, but for now I'll point to a couple of helpful resources: &lt;a href="http://www.codeplex.com/wsstudioexpress"&gt;Web Service Studio Express&lt;/a&gt; (the basis for the DynamicProxy code) and C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\DefaultWsdlHelpGenerator.aspx (the page that ASP.Net runs when you enter a WSDL location in IE).&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122650"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122650" 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/122650.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/06/05/contract-first-codegen.aspx</guid>
            <pubDate>Fri, 06 Jun 2008 02:45:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/122650.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/06/05/contract-first-codegen.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/122650.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>