Daniel Fisher (lennybacon.com)

SOA, DATA & THE WEB

Autorun T4 templates on build

  <ItemGroup>
    <T4Template Include="Model.tt">
      <Generator>TextTemplatingFileGenerator</Generator>
      <LastGenOutput>Model.cs</LastGenOutput>
    </T4Template>
  </ItemGroup>
  ...
    <!-- Define target for code generation -->
  <Target Name="T4Generation">
    <Message Text="Running Text Transformation..." />
    <Exec Command="&quot;TextTransform.exe&quot; &quot;%(T4Template.FullPath)&quot; -out @(T4Template->'%(FileName).wxs')" />
  </Target>
  <!-- Add target for code generation as dependency of "CoreCompile"-target -->
  <PropertyGroup>
    <CoreCompileDependsOn>@(CoreCompileDependsOn);T4Generation</CoreCompileDependsOn>
  </PropertyGroup>

Comments

Write a comment