Microsoft .NET comes with a build tool called "msbuild" which Novell Mono calls "xbuild". This document will use the name "msbuild" henceforth, but will be referring to both of them as they take the same input files and produce the same results.


<Project DefaultTargets="Build"



        <CobraFlags Include="-d"/>
        <CobraFlags Include="-correct-source"/>

        <CobraFiles Include="source\A.cobra"/>
        <CobraFiles Include="source\B.cobra"/>
        <CobraFiles Include="source\C.cobra"/>

        <References Include="System"/>
        <References Include="System.Web"/>


    <Target Name="Clean">
        <RemoveDir Directories="$(OutputDir)"/>

    <Target Name="Build">
        <CallTarget Targets="Reset"/>
        <Exec Command="cobra -c -t:lib @(CobraFlags, ' ') -out:$(OutputDir)/$(ProjectName).dll @(References -> '-ref:%(Identity)', ' ') @(CobraFiles, ' ')"/>

    <Target Name="Test">
        <CallTarget Targets="Reset"/>
        <Exec Command="cobra -test @(CobraFlags, ' ') -out:$(OutputDir)/$(ProjectName).dll @(References -> '-ref:%(Identity)', ' ') @(CobraFiles, ' ')"/>

    <Target Name="Reset">
        <CallTarget Targets="Clean"/>
        <MakeDir Condition="!Exists('$(OutputDir)')" Directories="$(OutputDir)"/>


Then at the command line, a simple "msbuild" (or "xbuild" on Mono) will pick the lone *.proj file and build its default target:


If there is more than one .proj file, you can pass it on the command line:

msbuild foo.proj

To build a specific target:

msbuild /t:test

Targets are case insensitive.


You don't need to use a build tool for single files or very small projects.

You can embed library references in your Cobra source code with the RefDirective? (@ref) and thereby skip passing them on the command line.

Alternatives to msbuild/xbuild include Nant, Make and scripts (such as bash or .bat).

See Also