<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Version specific targets/items/properties -->
  <PropertyGroup>
    <!-- MSBuild does not do short circuit evaluation of the AND operator, so we cannot have 
         something like '$(MSBuildToolsVersion)' != '' AND '$(MSBuildToolsVersion)' &gt;= '4.0'
         instead set as default and override -->

    <!-- MSBuild 4.0 -->
    <CodeSmithTaskAssemblyName>CodeSmith.MSBuild.v4.0, Version=6.0.4.0, Culture=neutral, PublicKeyToken=9fd61cdb91609a7a</CodeSmithTaskAssemblyName>
  </PropertyGroup>

  <UsingTask TaskName="CodeSmith.MSBuild.CodeSmith"
             AssemblyName="$(CodeSmithTaskAssemblyName)" />

  <!-- Inject into build -->
  <PropertyGroup>
    <ProductVersion>$(ProductVersion)</ProductVersion>
    <BuildDependsOn>CodeSmithGenerate;$(BuildDependsOn)</BuildDependsOn>
    <CodeSmithGenerateDependsOn>$(CodeSmithGenerateDependsOn)</CodeSmithGenerateDependsOn>
  </PropertyGroup>

  <!--Provide support for setting type (BuildAction) to Generate from VS-->
  <ItemGroup>
    <AvailableItemName Include="Generate"/>
  </ItemGroup>

  <Target Name="CodeSmithGenerate" Outputs="@(OutputFiles)"
          DependsOnTargets="$(CodeSmithGenerateDependsOn)">

    <CodeSmith ProjectFiles="@(Generate)" BuildFile="$(MSBuildProjectFullPath)">
      <Output TaskParameter="OutputFiles" ItemName="OutputFiles" />
      <Output TaskParameter="CompileFiles" ItemName="Compile" />
      <Output TaskParameter="References" ItemName="Reference" />
    </CodeSmith>

  </Target>

</Project>