<page xmlns="http://projectmallard.org/1.0/" type="guide" id="csharp">
<info>
    <link type="guide" xref="index#programs-and-libraries"/>
</info>

<title>C# Language Support</title>

<p>
Bake supports <link xref="programs">programs</link> and <link xref="libraries">libraries</link> written in the C# language.
Only the Mono compiler is supported.
</p>
<p>
C# programs and libraries can set the following program <link xref="variables">variables</link> to control compiling:
</p>
<table frame="all" shade="rows">
<thead>
<tr>
  <td><p>Name</p></td>
  <td><p>Description</p></td>
</tr>
</thead>
<tr>
  <td><p>libraries</p></td>
  <td><p>Libraries to use (see below for details)</p></td>
</tr>
<tr>
  <td><p>resources</p></td>
  <td><p>Resources to use (see below for details)</p></td>
</tr>
<tr>
  <td><p>compile-flags</p></td>
  <td><p>Additional command line flags to use when compiling</p></td>
</tr>
</table>
<example>
<p>
The following shows a recipe for a two file C# program:
</p>
<code>
programs.ExampleProgram {
  sources = Main.cs Module.cs
}
</code>
</example>
<p>
Libraries are specified using the <code>libraries</code> variable.
By default each library name listed is searched for in the system paths.
If the library is built inside the project then it will be searched for if the name is followed with <code>(local)</code>.
</p>
<example>
<p>
The following shows a recipe that builds a program and a library and links them together.
</p>
<code>
programs.ExampleProgram {
  sources = Main.cs
  libraries = ExampleLibrary (local)
}

libraries.ExampleLibrary {
  sources = Module.cs
}
</code>
</example>
<p>
C# programs and libraries can contain resource files.
Resources are specified using the <em>resources</em> variables.
By default the resource has the name of the file being embedded, this can be overridden by setting the resource id after the file name.
</p>
<example>
<p>
The following shows a C# program with an embedded icon file and a data file.
</p>
<code>
programs.ExampleProgram {
  sources = Main.cs
  resources = Icon.png \
              Data.xml (id special-data)
}
</code>
</example>
</page>
