title: Extending build process with calls to external programs that read ASCII files only
body: <p>I am extending the build process of my project to include generation of new source file from various models (<strike>Thrift IDL</strike> and others). I use C# with Visual Studio 2012.</p>
  
  <p>The generation logic is done by extending <code>BeforeBuild</code> target in <code>.csproj</code> file as the following:</p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;Thrift Include="IDL\*.thrift" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;Target Name="BeforeBuild"&gt;
    &lt;RemoveDir Directories="$(gendirs)"/&gt;
    &lt;MakeDir Directories="$(gendirs)" /&gt;
    &lt;XmlPeek XmlInputPath="@(MSBuildProjectDirectory\app.config" Query="/configurations/appSettings/add[@key='ThriftCompilerPath']/@value"&gt;
      &lt;Output TaskParameter="Result" ItemName="ThriftExec"/&gt;
    &lt;/XmlPeek&gt;
    &lt;Exec Command="$(ThriftExec) -v -out Gen\Thrift --gen csharp:hashcode %(Thrift.FullPath)" /&gt;
   ...
  &lt;/Target&gt;
  </code></pre>
  
  <p>The <code>.thrift</code> files are part of the project and are in UTF-8 format which seems to be an issue since the thrift compiler (and others) are not able to process UTF-8 formats and expect only ASCII. Feeding these files to the compiler causes errors.</p>
  
  <p>Is there a way such that the files are either saved in ASCII format or at least converted to ASCII format before feeding them to their corresponding compilers using msbuild? I think this is possible by deriving <a href="http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx" rel="nofollow">Task</a> class but I am looking for <em>hopefully</em> simpler solutions.</p>