How do I tell nant to only call csc when there are cs files in to compile?

Posted by rob_g on Stack Overflow See other posts from Stack Overflow or by rob_g
Published on 2010-06-17T01:05:33Z Indexed on 2010/06/17 1:12 UTC
Read the original article Hit count: 263

Filed under:
|

In my NAnt script I have a compile target that calls csc. Currently it fails because no inputs are specified:

  <target name="compile">
    <csc
      target="library"
      output="${umbraco.bin.dir}\Mammoth.${project::get-name()}.dll">
      <sources>
        <include name="project/*.cs" />
      </sources>
      <references>
      </references>
    </csc>    
  </target>

How do I tell NAnt to not execute the csc task if there are no CS files? I read about the 'if' attribute but am unsure what expression to use with it, as ${file::exists('*.cs')} does not work.

The build script is a template for Umbraco (a CMS) projects and may or may not ever have .cs source files in the project. Ideally I would like to not have developers need to remember to modify the NAnt script to include the compile task when .cs files are added to the project (or exclude it when all .cs files are removed).

© Stack Overflow or respective owner

Related posts about build-automation

Related posts about nant