c# compiler selection for the <script> task

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

c# compiler selection for the <script> task

keht

Hi all,

I want to use c# 3.0 features ("var" keyword, for example). But if I use it
in the <script language="c#"> task then I got compilation error. How I can
select c# compiler version there?

Thanks in advance!
--
View this message in context: http://old.nabble.com/c--compiler-selection-for-the-%3Cscript%3E-task-tp30019135p30019135.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: c# compiler selection for the <script> task

Liam_Kenny
I am not exactly sure what you are asking, as your post is a bit unclear.

if you want to use C# 3 features in your app, make sure you have the proper version installed and your app is referencing them.  In addition, this listserv is not the proper place to post this question.

if you want Nant to reference a version of the framework that uses C#3 and allows the var keyword, make sure you are referencing the correct framework in your Nant.exe,.config file in your bin directory.

LK





From:        keht <[hidden email]>
To:        [hidden email]
Date:        10/21/2010 08:46 AM
Subject:        [NAnt-users]  c# compiler selection for the <script> task





Hi all,

I want to use c# 3.0 features ("var" keyword, for example). But if I use it
in the <script language="c#"> task then I got compilation error. How I can
select c# compiler version there?

Thanks in advance!
--
View this message in context:
http://old.nabble.com/c--compiler-selection-for-the-%3Cscript%3E-task-tp30019135p30019135.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: c# compiler selection for the <script> task

keht
Sorry for unclear explanations... For example, this code returns an error:

<project name="Test" default="run">
    <property name="nant.settings.currentframework" value="net-3.5" />
    <target name="run">
        <script language="C#" mainclass="Test">
            <code>
                <![CDATA[
                    class Test {
                        public static void ScriptMain(Project project)
                        {
                            var s = "Hello world";
                            Console.WriteLine(s);

                        }
                    }
                ]]>
            </code>
        </script>
    </target>
</project>


Buildfile: file:///c:/_nant-0.91-alpha2/examples/ScriptTask/script-sample.build
Target framework: Microsoft .NET Framework 3.5
Target(s) specified: run

run:
BUILD FAILED
c:\_nant-0.91-alpha2\examples\ScriptTask\script-sample.build(4,10):

Compilation failed:
[...]\Temp\h7ph1r09.0.cs(27,29) : error CS0246: The type or namespace name 'var' could not be found[...]

I don't understand why it happens. Framework is changed to 3.5 but script code is compiled using csc v2.0.

----
Regards, keht


On Thu, Oct 21, 2010 at 16:02, <[hidden email]> wrote:
I am not exactly sure what you are asking, as your post is a bit unclear.

if you want to use C# 3 features in your app, make sure you have the proper version installed and your app is referencing them.  In addition, this listserv is not the proper place to post this question.

if you want Nant to reference a version of the framework that uses C#3 and allows the var keyword, make sure you are referencing the correct framework in your Nant.exe,.config file in your bin directory.

LK





From:        keht <[hidden email]>
To:        [hidden email]
Date:        10/21/2010 08:46 AM
Subject:        [NAnt-users]  c# compiler selection for the <script> task





Hi all,

I want to use c# 3.0 features ("var" keyword, for example). But if I use it
in the <script language="c#"> task then I got compilation error. How I can
select c# compiler version there?

Thanks in advance!
--
View this message in context:
http://old.nabble.com/c--compiler-selection-for-the-%3Cscript%3E-task-tp30019135p30019135.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: c# compiler selection for the <script> task

Liam_Kenny
yeah, that is odd.  I cannot get var to work.
I changed my .config file settings as well to point to 3.5, but still getting an error.




From:        keht <[hidden email]>
To:        [hidden email]
Cc:        [hidden email]
Date:        10/21/2010 09:49 AM
Subject:        Re: [NAnt-users] c# compiler selection for the <script> task




Sorry for unclear explanations... For example, this code returns an error:

<project name="Test" default="run">
    <property name="nant.settings.currentframework" value="net-3.5" />
    <target name="run">
        <script language="C#" mainclass="Test">
            <code>
                <![CDATA[
                    class Test {
                        public static void ScriptMain(Project project)
                        {
                            var s = "Hello world";
                            Console.WriteLine(s);

                        }
                    }
                ]]>
            </code>
        </script>
    </target>
</project>


Buildfile:
file:///c:/_nant-0.91-alpha2/examples/ScriptTask/script-sample.build
Target framework: Microsoft .NET Framework 3.5

Target(s) specified: run

run:
BUILD FAILED
c:\_nant-0.91-alpha2\examples\ScriptTask\script-sample.build(4,10):

Compilation failed:
[...]\Temp\h7ph1r09.0.cs(27,29) : error CS0246: The type or namespace name 'var' could not be found[...]

I don't understand why it happens. Framework is changed to 3.5 but script code is compiled using csc v2.0.

----
Regards, keht


On Thu, Oct 21, 2010 at 16:02, <Liam_Kenny@...> wrote:
I am not exactly sure what you are asking, as your post is a bit unclear.

if you want to use C# 3 features in your app, make sure you have the proper version installed and your app is referencing them.  In addition, this listserv is not the proper place to post this question.


if you want Nant to reference a version of the framework that uses C#3 and allows the var keyword, make sure you are referencing the correct framework in your Nant.exe,.config file in your bin directory.


LK






From:        
keht <xy2041@...>
To:        
[hidden email]
Date:        
10/21/2010 08:46 AM
Subject:        
[NAnt-users]  c# compiler selection for the <script> task






Hi all,

I want to use c# 3.0 features ("var" keyword, for example). But if I use it
in the <script language="c#"> task then I got compilation error. How I can
select c# compiler version there?

Thanks in advance!
--
View this message in context:
http://old.nabble.com/c--compiler-selection-for-the-%3Cscript%3E-task-tp30019135p30019135.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store

http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list

[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: c# compiler selection for the <script> task

drieseng
Administrator

Hi Liam,

 

We use CodeDOM to compile the script, and hence it uses the C# compiler corresponding to the CLR on which NAnt is running.

The current target framework – as specified using the nant.settings.currentframework – does not affect this.

 

I’d appreciate it if you’d submit a (documentation) bug report for this.

 

Hope this helps,

 

Gert

 

From: [hidden email] [mailto:[hidden email]]
Sent: donderdag 21 oktober 2010 21:09
To: keht
Cc: [hidden email]
Subject: Re: [NAnt-users] c# compiler selection for the <script> task

 

yeah, that is odd.  I cannot get var to work.
I changed my .config file settings as well to point to 3.5, but still getting an error.




From:        keht <[hidden email]>
To:        [hidden email]
Cc:        [hidden email]
Date:        10/21/2010 09:49 AM
Subject:        Re: [NAnt-users] c# compiler selection for the <script> task





Sorry for unclear explanations... For example, this code returns an error:

<project name="Test" default="run">
    <property name="nant.settings.currentframework" value="net-3.5" />
    <target name="run">
        <script language="C#" mainclass="Test">
            <code>
                <![CDATA[
                    class Test {
                        public static void ScriptMain(Project project)
                        {
                            var s = "Hello world";
                            Console.WriteLine(s);

                        }
                    }
                ]]>
            </code>
        </script>
    </target>
</project>


Buildfile: <a href="file:///c:\_nant-0.91-alpha2\examples\ScriptTask\script-sample.build">file:///c:/_nant-0.91-alpha2/examples/ScriptTask/script-sample.build
Target framework: Microsoft .NET Framework 3.5

Target(s) specified: run

run:
BUILD FAILED
c:\_nant-0.91-alpha2\examples\ScriptTask\script-sample.build(4,10):

Compilation failed:
[...]\Temp\h7ph1r09.0.cs(27,29) : error CS0246: The type or namespace name 'var' could not be found[...]

I don't understand why it happens. Framework is changed to 3.5 but script code is compiled using csc v2.0.

----
Regards, keht


On Thu, Oct 21, 2010 at 16:02, <[hidden email]> wrote:
I am not exactly sure what you are asking, as your post is a bit unclear.

if you want to use C# 3 features in your app, make sure you have the proper version installed and your app is referencing them.  In addition, this listserv is not the proper place to post this question.


if you want Nant to reference a version of the framework that uses C#3 and allows the var keyword, make sure you are referencing the correct framework in your Nant.exe,.config file in your bin directory.


LK






From:        
keht <[hidden email]>
To:        
[hidden email]
Date:        
10/21/2010 08:46 AM
Subject:        
[NAnt-users]  c# compiler selection for the <script> task







Hi all,

I want to use c# 3.0 features ("var" keyword, for example). But if I use it
in the <script language="c#"> task then I got compilation error. How I can
select c# compiler version there?

Thanks in advance!
--
View this message in context:
http://old.nabble.com/c--compiler-selection-for-the-%3Cscript%3E-task-tp30019135p30019135.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store

http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.856 / Virus Database: 271.1.1/3210 - Release Date: 10/21/10 08:34:00


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: c# compiler selection for the <script> task

keht
In reply to this post by Liam_Kenny
The only way to avoid it (that I found) - nant source code editing. Just hardcode compiler version into the <script> task implementation... But it is the bad solution... Anyway, it works for me:
 
CSharpCodeProvider sharpCompiler = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } });
CompilerResults results = sharpCompiler.CompileAssemblyFromDom(options, compileUnit);

----
Regards, keht


On Thu, Oct 21, 2010 at 23:15, <[hidden email]> wrote:
yeah, that is cool.
if you run:

<?xml version="1.0"?>
<project name="Test" default="run" basedir=".">
        <description></description>  
        <property name="debug" value="true"/>
        <property name="nant.settings.currentframework" value="net-3.5" />
        <target name="run">
                <script language="c#">
                    <code>
                                <![CDATA[
                              public static void ScriptMain(Project project)
                              {
                                      string str = "Hello World from Nant C# ";
                                      string ver = System.Environment.Version.ToString();
                                  project.Log(Level.Info, str.ToString() + ver);
                              }
                           ]]>
                    </code>
            </script>
        </target>
</project>

you will see it is still on 2.0




From:        "Gert Driesen" <[hidden email]>
To:        <[hidden email]>, "'keht'" <[hidden email]>
Cc:        <[hidden email]>
Date:        10/21/2010 03:58 PM
Subject:        RE: [NAnt-users] c# compiler selection for the <script> task




Hi Liam,
 
We use CodeDOM to compile the script, and hence it uses the C# compiler corresponding to the CLR on which NAnt is running.
The current target framework – as specified using the nant.settings.currentframework – does not affect this.
 
I’d appreciate it if you’d submit a (documentation) bug report for this.
 
Hope this helps,
 
Gert
 
From: [hidden email] [[hidden email]
]
Sent:
donderdag 21 oktober 2010 21:09
To:
keht

Subject:
Re: [NAnt-users] c# compiler selection for the <script> task

 
yeah, that is odd.  I cannot get var to work.
I changed my .config file settings as well to point to 3.5, but still getting an error.





From:        
keht <[hidden email]>
To:        
[hidden email]
Cc:        
[hidden email]
Date:        
10/21/2010 09:49 AM
Subject:        
Re: [NAnt-users] c# compiler selection for the <script> task






Sorry for unclear explanations... For example, this code returns an error:

<project name="Test" default="run">
   <property name="nant.settings.currentframework" value="net-3.5" />
   <target name="run">
       <script language="C#" mainclass="Test">
           <code>
               <![CDATA[
                   class Test {
                       public static void ScriptMain(Project project)
                       {
                           var s = "Hello world";
                           Console.WriteLine(s);

                       }
                   }
               ]]>
           </code>
       </script>
   </target>
</project>


Buildfile:
file:///c:/_nant-0.91-alpha2/examples/ScriptTask/script-sample.build
Target framework: Microsoft .NET Framework 3.5

Target(s) specified: run

run:
BUILD FAILED
c:\_nant-0.91-alpha2\examples\ScriptTask\script-sample.build(4,10):

Compilation failed:
[...]\Temp\h7ph1r09.0.cs(27,29) : error CS0246: The type or namespace name 'var' could not be found[...]

I don't understand why it happens. Framework is changed to 3.5 but script code is compiled using csc v2.0.

----
Regards, keht


On Thu, Oct 21, 2010 at 16:02, <
[hidden email]> wrote:
I am not exactly sure what you are asking, as your post is a bit unclear.


if you want to use C# 3 features in your app, make sure you have the proper version installed and your app is referencing them.  In addition, this listserv is not the proper place to post this question.


if you want Nant to reference a version of the framework that uses C#3 and allows the var keyword, make sure you are referencing the correct framework in your Nant.exe,.config file in your bin directory.


LK






From:        
keht <[hidden email]>
To:        
[hidden email]
Date:        
10/21/2010 08:46 AM
Subject:        
[NAnt-users]  c# compiler selection for the <script> task








Hi all,

I want to use c# 3.0 features ("var" keyword, for example). But if I use it
in the <script language="c#"> task then I got compilation error. How I can
select c# compiler version there?

Thanks in advance!
--
View this message in context:
http://old.nabble.com/c--compiler-selection-for-the-%3Cscript%3E-task-tp30019135p30019135.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store

http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list

[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store

http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
NAnt-users mailing list
[hidden email]

https://lists.sourceforge.net/lists/listinfo/nant-users

 
 
The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.

No virus found in this incoming message.
Checked by AVG -
www.avg.com


Version: 9.0.856 / Virus Database: 271.1.1/3210 - Release Date: 10/21/10 08:34:00

 
 

The information transmitted is intended only for the
person or entity to which it is addressed and may
contain confidential and/or privileged material. Any
review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this
information by persons or entities other than the
intended recipient is prohibited. If you received this
in error, please delete the material from any
computer.



------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
NAnt-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nant-users
Loading...