[Mono-dev] Conditional compilation

Gert Driesen gert.driesen at telenet.be
Thu Aug 30 16:00:55 EDT 2007


Pablo,

What happens if you compile using gmcs, because NAnt is probably targeting
the 2.0 profile ?

I know there's a issue in gmcs where conditional compilation does not work
correct for generic methods
(http://bugzilla.ximian.com/show_bug.cgi?id=82443), but it should work for
non-generic methods.

Gert

-----Original Message-----
From: mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of
pablosantosluac
Sent: donderdag 30 augustus 2007 21:38
To: mono-devel-list at lists.ximian.com
Subject: [Mono-dev] Conditional compilation

Hi,

I have a code fragment like the following:

using System;
using System.Diagnostics;


namespace conditionalcompilation
{
 class Class1
 {
  static void Main(string[] args)
  {
   Class1 me = new Class1();
   me.Go();
  }

  [Conditional("YELLOW")]
  public void Go()
  {
   Console.WriteLine("Hello");
  }
 }
}


And the nant build file is:

<?xml version="1.0"?>
<project name="client" default="build" basedir="">

    <description>TEST</description>

    <property name="debug" value="true" overwrite="false" />

    <target name="build" depends="conditional" />

    <target name="conditional" description="conditional" >

        <csc target="winexe" output="conditional.exe" debug="${debug}" 
define="${define}" >
            <sources>
                <include name="*.cs" />
            </sources>
            <references>
                <include name="System.Windows.Forms.dll" />
                <include name="System.Drawing.dll" />
                <include name="System.Data.dll" />
            </references>
        </csc>
    </target>
</project>

I build it with latest mono (1.2.5) (same results with 1.2.4): 
nant.bat -D:define=YELLOW -v -t:mono-1.0

conditional:

      [csc] 'D:\data\develop\conditionalcompilation\aaa.cs' has been
updated, recompiling.
      [csc] Compiling 3 files to
'D:\data\develop\conditionalcompilation\conditional.exe'.
      [csc] Contents of C:\DOCUME~1\pablo\CONFIG~1\Temp\tmp445918bc.tmp.
      [csc] /fullpaths
      [csc] /debug
      [csc] "/define:DEBUG"
      [csc] "/define:TRACE"
      [csc] /nologo
      [csc] "/target:winexe"
      [csc] "/define:YELLOW"
      [csc] "/out:D:\data\develop\conditionalcompilation\conditional.exe"
      [csc] "/reference:C:\Archivos de
programa\Mono-1.2.4\lib\mono\1.0\System.Windows.Forms.dll"
      [csc] "/reference:C:\Archivos de
programa\Mono-1.2.4\lib\mono\1.0\System.Drawing.dll"
      [csc] "/reference:C:\Archivos de
programa\Mono-1.2.4\lib\mono\1.0\System.Data.dll"
      [csc] "D:\data\develop\conditionalcompilation\aaa.cs"
      [csc] "D:\data\develop\conditionalcompilation\AssemblyInfo.cs"
      [csc] "D:\data\develop\conditionalcompilation\Class1.cs"
      [csc]


But when I run the app no output is generated.

If I compile it directly with mcs it works as expected, printing the
Console.WriteLine message.

Do you find something wrong? Is it a bug on Nant?

Thanks,

pablo 

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list